-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also has the advantage of possibly being smaller, as there is less code to be included.
- Loading branch information
Showing
9 changed files
with
119 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![forbid(unsafe_code)] | ||
|
||
mod plumbing; | ||
|
||
use anyhow::Result; | ||
|
||
#[cfg(feature = "pretty-cli")] | ||
fn main() -> Result<()> { | ||
plumbing::pretty::main() | ||
} | ||
|
||
#[cfg(all(feature = "lean-cli", not(feature = "pretty-cli")))] | ||
fn main() -> Result<()> { | ||
plumbing::lean::main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
mod options { | ||
use argh::FromArgs; | ||
use std::path::PathBuf; | ||
|
||
#[derive(FromArgs)] | ||
/// A simple calculation tool | ||
pub struct Args { | ||
#[argh(subcommand)] | ||
pub subcommand: SubCommands, | ||
} | ||
|
||
#[derive(FromArgs, PartialEq, Debug)] | ||
#[argh(subcommand)] | ||
pub enum SubCommands { | ||
VerifyPack(VerifyPack), | ||
} | ||
|
||
/// Initialize the repository in the current directory. | ||
#[derive(FromArgs, PartialEq, Debug)] | ||
#[argh(subcommand, name = "verify-pack")] | ||
pub struct VerifyPack { | ||
/// the '.pack' or '.idx' file whose checksum to validate. | ||
#[argh(positional)] | ||
pub path: PathBuf, | ||
} | ||
} | ||
|
||
use anyhow::Result; | ||
use gitoxide_core as core; | ||
use std::io::{stderr, stdout}; | ||
|
||
pub fn main() -> Result<()> { | ||
pub use options::*; | ||
let cli: Args = argh::from_env(); | ||
match cli.subcommand { | ||
SubCommands::VerifyPack(VerifyPack { path }) => { | ||
core::verify_pack_or_pack_index(path, stdout(), stderr()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(feature = "pretty-cli")] | ||
pub mod pretty; | ||
|
||
#[cfg(all(feature = "lean-cli", not(feature = "pretty-cli")))] | ||
pub mod lean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use anyhow::Result; | ||
use gitoxide_core as core; | ||
use std::io::{stderr, stdout}; | ||
use structopt::StructOpt; | ||
|
||
mod options { | ||
use std::path::PathBuf; | ||
use structopt::{clap::AppSettings, StructOpt}; | ||
|
||
#[derive(Debug, StructOpt)] | ||
#[structopt(about = "The git, simply swift")] | ||
#[structopt(settings = &[AppSettings::SubcommandRequired, | ||
AppSettings::ColoredHelp])] | ||
pub struct Args { | ||
#[structopt(subcommand)] | ||
pub cmd: Subcommands, | ||
} | ||
|
||
#[derive(Debug, StructOpt)] | ||
pub enum Subcommands { | ||
/// Verify the integrity of a pack or index file | ||
#[structopt(setting = AppSettings::ColoredHelp)] | ||
VerifyPack { | ||
/// The '.pack' or '.idx' file whose checksum to validate. | ||
#[structopt(parse(from_os_str))] | ||
path: PathBuf, | ||
}, | ||
} | ||
} | ||
|
||
pub fn main() -> Result<()> { | ||
use options::*; | ||
let args = Args::from_args(); | ||
match args.cmd { | ||
Subcommands::VerifyPack { path } => { | ||
core::verify_pack_or_pack_index(path, stdout(), stderr()) | ||
} | ||
}?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters