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    /// Render the picker inline (non-fullscreen), useful for shell key bindings
37    #[arg(long)]
38    pub inline_picker: bool,
39
40    /// Inline picker height in terminal rows (default: 18)
41    #[arg(long, value_name = "LINES", requires = "inline_picker")]
42    pub inline_height: Option<u16>,
43}
44
45#[derive(ValueEnum, Clone, Copy, PartialEq, Eq, Debug, Hash)]
46pub enum Shell {
47    Fish,
48    Zsh,
49    Bash,
50    #[allow(clippy::enum_variant_names)]
51    NuShell,
52    #[allow(clippy::enum_variant_names)]
53    PowerShell,
54}