use std::ffi::OsString;
#[derive(Debug, StructOpt, Clone)]
pub struct CrateSelector {
pub name: Option<String>,
pub version: Option<String>,
}
#[derive(Debug, StructOpt, Clone)]
pub struct NewId {
#[structopt(long = "url")]
pub url: Option<String>,
#[structopt(long = "github-username")]
pub github_username: Option<String>,
#[structopt(long = "https-push")]
pub use_https_push: bool,
}
#[derive(Debug, StructOpt, Clone)]
pub enum New {
#[structopt(name = "id")]
Id(NewId),
}
#[derive(Debug, StructOpt, Clone)]
pub struct SwitchId {
pub id: String,
}
#[derive(Debug, StructOpt, Clone)]
pub struct TrustParams {
#[structopt(long = "depth", default_value = "10")]
pub depth: u64,
#[structopt(long = "high-cost", default_value = "0")]
pub high_cost: u64,
#[structopt(long = "medium-cost", default_value = "1")]
pub medium_cost: u64,
#[structopt(long = "low-cost", default_value = "5")]
pub low_cost: u64,
}
impl From<TrustParams> for crev_lib::TrustDistanceParams {
fn from(params: TrustParams) -> Self {
crev_lib::TrustDistanceParams {
max_distance: params.depth,
high_trust_distance: params.high_cost,
medium_trust_distance: params.medium_cost,
low_trust_distance: params.low_cost,
}
}
}
#[derive(Debug, StructOpt, Clone)]
pub struct VerifyDeps {
#[structopt(long = "verbose", short = "v")]
pub verbose: bool,
#[structopt(flatten)]
pub trust_params: TrustParams,
#[structopt(long = "skip-verified")]
pub skip_verified: bool,
#[structopt(long = "skip-known-owners")]
pub skip_known_owners: bool,
#[structopt(long = "for-id")]
pub for_id: Option<String>,
}
#[derive(Debug, StructOpt, Clone)]
pub enum Verify {
#[structopt(
name = "deps",
after_help = r"This will show the following information:
- trust - Effective trust level trusted reviewers or `none`, `flagged`
- reviews - Number of reviews for the specific version and for all versions
- downloads - Download counts from crates.io for the specific version and all versions
- own. - Owner counts from crates.io (known/all)
- lines - Lines of Rust code
- flgs - Flags for specific types of packages
- CB - Custom Build
- name - Crate name
- version - Crate version"
)]
Deps(VerifyDeps),
}
#[derive(Debug, StructOpt, Clone)]
pub struct Trust {
pub pub_ids: Vec<String>,
#[structopt(flatten)]
pub common_proof_create: CommonProofCreate,
}
#[derive(Debug, StructOpt, Clone)]
pub struct FetchUrl {
pub url: String,
}
#[derive(Debug, StructOpt, Clone)]
pub enum Fetch {
#[structopt(name = "trusted")]
Trusted(TrustParams),
#[structopt(name = "url")]
Url(FetchUrl),
#[structopt(name = "all")]
All,
}
#[derive(Debug, StructOpt, Clone)]
pub enum QueryId {
#[structopt(name = "current")]
Current,
#[structopt(name = "all")]
All,
#[structopt(name = "own")]
Own,
#[structopt(name = "trusted")]
Trusted {
#[structopt(flatten)]
trust_params: TrustParams,
#[structopt(long = "for-id")]
for_id: Option<String>,
},
}
#[derive(Debug, StructOpt, Clone)]
pub struct QueryReview {
#[structopt(flatten)]
pub crate_: CrateSelector,
}
#[derive(Debug, StructOpt, Clone)]
pub enum Query {
#[structopt(name = "id")]
Id(QueryId),
#[structopt(name = "review")]
Review(QueryReview),
}
#[derive(Debug, StructOpt, Clone)]
pub enum Switch {
#[structopt(name = "id")]
Id(SwitchId),
}
#[derive(Debug, StructOpt, Clone)]
pub enum Edit {
#[structopt(name = "readme")]
Readme,
#[structopt(name = "config")]
Config,
#[structopt(name = "known")]
Known,
}
#[derive(Debug, StructOpt, Clone)]
pub struct Git {
#[structopt(parse(from_os_str))]
pub args: Vec<OsString>,
}
#[derive(Debug, StructOpt, Clone)]
pub struct ReviewOrGotoCommon {
#[structopt(flatten)]
pub crate_: CrateSelector,
#[structopt(long = "unrelated", short = "u")]
pub unrelated: bool,
}
#[derive(Debug, StructOpt, Clone)]
pub struct Open {
#[structopt(long = "cmd")]
pub cmd: Option<String>,
#[structopt(long = "cmd-save")]
pub cmd_save: bool,
#[structopt(flatten)]
pub common: ReviewOrGotoCommon,
}
#[derive(Debug, StructOpt, Clone)]
pub struct CommonProofCreate {
#[structopt(long = "no-commit")]
pub no_commit: bool,
#[structopt(long = "print-unsigned")]
pub print_unsigned: bool,
#[structopt(long = "print-signed")]
pub print_signed: bool,
#[structopt(long = "no-store")]
pub no_store: bool,
}
#[derive(Debug, StructOpt, Clone)]
pub struct Review {
#[structopt(flatten)]
pub common: ReviewOrGotoCommon,
#[structopt(flatten)]
pub common_proof_create: CommonProofCreate,
}
#[derive(Debug, StructOpt, Clone)]
pub struct ExportId {
pub id: Option<String>,
}
#[derive(Debug, StructOpt, Clone)]
pub enum Export {
#[structopt(name = "id")]
Id(ExportId),
}
#[derive(Debug, StructOpt, Clone)]
pub enum Import {
#[structopt(name = "id")]
Id,
#[structopt(name = "proof")]
Proof(ImportProof),
}
#[derive(Debug, StructOpt, Clone)]
pub struct ImportProof {
#[structopt(long = "reset-date")]
pub reset_date: bool,
#[structopt(flatten)]
pub common: CommonProofCreate,
}
#[derive(Debug, StructOpt, Clone)]
pub enum Command {
#[structopt(name = "new")]
New(New),
#[structopt(name = "switch")]
Switch(Switch),
#[structopt(name = "edit")]
Edit(Edit),
#[structopt(name = "verify")]
Verify(Verify),
#[structopt(name = "review")]
Review(Review),
#[structopt(name = "flag")]
Flag(Review),
#[structopt(name = "query")]
Query(Query),
#[structopt(name = "trust")]
Trust(Trust),
#[structopt(name = "distrust")]
Distrust(Trust),
#[structopt(name = "fetch")]
Fetch(Fetch),
#[structopt(name = "git")]
#[structopt(raw(setting = "structopt::clap::AppSettings::TrailingVarArg"))]
Git(Git),
#[structopt(name = "push")]
Push,
#[structopt(name = "publish")]
Publish,
#[structopt(name = "pull")]
Pull,
#[structopt(name = "goto")]
Goto(ReviewOrGotoCommon),
#[structopt(name = "open")]
Open(Open),
#[structopt(name = "clean")]
Clean(ReviewOrGotoCommon),
#[structopt(name = "export")]
Export(Export),
#[structopt(name = "import")]
Import(Import),
#[structopt(name = "update")]
Update,
}
#[derive(Debug, StructOpt, Clone)]
pub enum MainCommand {
#[structopt(name = "crev")]
Crev(Command),
}
#[derive(Debug, StructOpt, Clone)]
#[structopt(name = "crev", about = "Distributed code review system")]
pub struct Opts {
#[structopt(subcommand)]
pub command: MainCommand,
}