Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2024"

[dependencies]
clap = { version = "4.5", features = ["derive", "env"] }
49 changes: 48 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
use clap::{ArgGroup, Parser, Subcommand};
use std::path::PathBuf;

/// Analyze CI and best practices across Rust project repos
#[derive(Parser)]
#[command(name = "crabwatch", version, about, long_about = None)]
struct Cli {
/// Increase logging verbosity
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
verbose: u8,

/// Directory where downloaded workflows are cached
#[arg(long, global = true)]
cache_dir: Option<PathBuf>,

/// GitHub token
#[arg(long, env = "GITHUB_TOKEN", hide_env_values = true, global = true)]
github_token: Option<String>,

#[command(subcommand)]
command: Command,
}

#[derive(Subcommand)]
enum Command {
/// Analyze a repository or an organization
#[command(group(ArgGroup::new("target").required(true).args(["repo", "org"])))]
Analyze {
/// Analyze a single repository
#[arg(long)]
repo: Option<String>,

/// Analyze every repository in an organization
#[arg(long)]
org: Option<String>,

/// Specific check to run (runs all if omitted)
#[arg(long)]
check: Option<String>,
},
}

fn main() {
println!("Hello, world!");
let cli = Cli::parse();
match cli.command {
Command::Analyze { repo, org, check } => {
println!("analyze repo={repo:?} org={org:?} check={check:?}");
}
}
}