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    /// Generate shell completion script for tab completion of directory names
25    #[arg(long)]
26    pub completions: Option<Shell>,
27
28    /// Use shallow clone (--depth 1) when cloning repositories
29    #[arg(short, long)]
30    pub shallow_clone: bool,
31
32    /// Create a git worktree from current repository (must be inside a git repo)
33    #[arg(short = 'w', long = "worktree", value_name = "WORKTREE_NAME")]
34    pub worktree: Option<String>,
35}
36
37#[derive(ValueEnum, Clone, Copy, PartialEq, Eq, Debug, Hash)]
38pub enum Shell {
39    Fish,
40    Zsh,
41    Bash,
42    #[allow(clippy::enum_variant_names)]
43    NuShell,
44    #[allow(clippy::enum_variant_names)]
45    PowerShell,
46}