Skip to main content

try_rs/
cli.rs

1use clap::{Parser, ValueEnum};
2
3#[derive(Parser)]
4#[command(name = "try-rs")]
5#[command(about = format!("🦀 try-rs {} 🦀\nA blazing fast, Rust-based workspace manager for your temporary experiments.", env!("CARGO_PKG_VERSION")), long_about = None)]
6#[command(version = env!("CARGO_PKG_VERSION"))]
7pub struct Cli {
8    /// Create or jump to an experiment / Clone a git URL. Starts TUI if omitted
9    #[arg(value_name = "NAME_OR_URL")]
10    pub name_or_url: Option<String>,
11
12    /// Destination folder name when cloning a repository
13    #[arg(value_name = "DESTINATION")]
14    pub destination: Option<String>,
15
16    /// Generate shell integration code for the specified shell
17    #[arg(long)]
18    pub setup: Option<Shell>,
19
20    /// Print shell integration code to stdout (for use with tools like Nix home-manager)
21    #[arg(long)]
22    pub setup_stdout: Option<Shell>,
23
24    /// Use shallow clone (--depth 1) when cloning repositories
25    #[arg(short, long)]
26    pub shallow_clone: bool,
27
28    /// Create a git worktree from current repository (must be inside a git repo)
29    #[arg(short = 'w', long = "worktree", value_name = "WORKTREE_NAME")]
30    pub worktree: Option<String>,
31}
32
33#[derive(ValueEnum, Clone, Copy, PartialEq, Eq, Debug, Hash)]
34pub enum Shell {
35    Fish,
36    Zsh,
37    Bash,
38    #[allow(clippy::enum_variant_names)]
39    NuShell,
40    #[allow(clippy::enum_variant_names)]
41    PowerShell,
42}