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    /// Remove shell integration for all installed shells
25    #[arg(long)]
26    pub setup_clear: bool,
27
28    /// Generate shell completion script for tab completion of directory names
29    #[arg(long)]
30    pub completions: Option<Shell>,
31
32    /// Use shallow clone (--depth 1) when cloning repositories
33    #[arg(short, long)]
34    pub shallow_clone: bool,
35
36    /// Create a git worktree from current repository (must be inside a git repo)
37    #[arg(short = 'w', long = "worktree", value_name = "WORKTREE_NAME")]
38    pub worktree: Option<String>,
39
40    /// Render the picker inline (non-fullscreen), useful for shell key bindings
41    #[arg(long)]
42    pub inline_picker: bool,
43
44    /// Inline picker height in terminal rows (default: 18)
45    #[arg(long, value_name = "LINES", requires = "inline_picker")]
46    pub inline_height: Option<u16>,
47
48    /// Show the disk information panel in the TUI
49    #[arg(long, overrides_with = "hide_disk", action = clap::ArgAction::SetTrue)]
50    pub show_disk: bool,
51
52    /// Hide the disk information panel in the TUI
53    #[arg(
54        long,
55        overrides_with = "show_disk",
56        action = clap::ArgAction::SetFalse,
57        default_value_t = true
58    )]
59    pub hide_disk: bool,
60
61    /// Show the preview panel in the TUI
62    #[arg(long, overrides_with = "hide_preview", action = clap::ArgAction::SetTrue)]
63    pub show_preview: bool,
64
65    /// Hide the preview panel in the TUI
66    #[arg(
67        long,
68        overrides_with = "show_preview",
69        action = clap::ArgAction::SetFalse,
70        default_value_t = true
71    )]
72    pub hide_preview: bool,
73
74    /// Show the icon legend panel in the TUI
75    #[arg(long, overrides_with = "hide_legend", action = clap::ArgAction::SetTrue)]
76    pub show_legend: bool,
77
78    /// Hide the icon legend panel in the TUI
79    #[arg(
80        long,
81        overrides_with = "show_legend",
82        action = clap::ArgAction::SetFalse,
83        default_value_t = true
84    )]
85    pub hide_legend: bool,
86
87    /// Show the right panel in the TUI
88    #[arg(long, overrides_with = "hide_right_panel", action = clap::ArgAction::SetTrue)]
89    pub show_right_panel: bool,
90
91    /// Hide the right panel in the TUI
92    #[arg(
93        long,
94        overrides_with = "show_right_panel",
95        action = clap::ArgAction::SetFalse,
96        default_value_t = true
97    )]
98    pub hide_right_panel: bool,
99}
100
101#[derive(ValueEnum, Clone, Copy, PartialEq, Eq, Debug, Hash)]
102pub enum Shell {
103    Fish,
104    Zsh,
105    Bash,
106    #[allow(clippy::enum_variant_names)]
107    NuShell,
108    #[allow(clippy::enum_variant_names)]
109    PowerShell,
110}