use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "gittype")]
#[command(
about = "A typing practice tool using your own code repositories - extracts all code chunks (functions, classes, methods, etc.)",
long_about = "GitType turns your own source code into typing challenges. \
Practice typing by using functions, classes, and methods from your actual projects. \
\n\nExamples:\n \
gittype # Use current directory\n \
gittype /path/to/repo # Use specific repository\n \
gittype --repo owner/repo # Clone and use GitHub repository\n \
gittype --langs rust,python # Filter by languages"
)]
#[command(version = env!("CARGO_PKG_VERSION"))]
pub struct Cli {
#[arg(
value_name = "REPO_PATH",
help = "Repository path to extract code from"
)]
pub repo_path: Option<PathBuf>,
#[arg(
long,
help = "GitHub repository URL or path to clone and play with",
long_help = "GitHub repository URL or path to clone and play with. \
Supports formats:\n \
- owner/repo\n \
- https://github.com/owner/repo\n \
- git@github.com:owner/repo.git"
)]
pub repo: Option<String>,
#[arg(
long,
value_delimiter = ',',
help = "Filter by programming languages (comma-separated)",
long_help = "Filter by programming languages (comma-separated). \
Supported languages:\n \
rust, typescript, javascript, python, ruby, go, swift, \
kotlin, java, php, csharp, c, cpp, haskell, dart, scala, zig, elixir, erlang\n \
Example: --langs rust,python,typescript"
)]
pub langs: Option<Vec<String>>,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand)]
pub enum Commands {
History,
Stats,
Export {
#[arg(long, default_value = "json")]
format: String,
#[arg(long)]
output: Option<PathBuf>,
},
Cache {
#[command(subcommand)]
cache_command: CacheCommands,
},
Repo {
#[command(subcommand)]
repo_command: RepoCommands,
},
Trending {
#[arg(
help = "Programming language to filter trending repositories",
long_help = "Programming language to filter trending repositories.\nSupported languages: C, C#, C++, Dart, Elixir, Erlang, Go, Haskell, Java, JavaScript, Kotlin, PHP, Python, Ruby, Rust, Scala, Swift, TypeScript, Zig"
)]
language: Option<String>,
repo_name: Option<String>,
#[arg(long, default_value = "daily")]
period: String,
},
}
#[derive(Subcommand)]
pub enum CacheCommands {
Stats,
Clear,
List,
}
#[derive(Subcommand)]
pub enum RepoCommands {
List,
Clear {
#[arg(long)]
force: bool,
},
Play,
}