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    /// Show the disk information panel in the TUI
45    #[arg(long, overrides_with = "hide_disk", action = clap::ArgAction::SetTrue)]
46    pub show_disk: bool,
47
48    /// Hide the disk information panel in the TUI
49    #[arg(
50        long,
51        overrides_with = "show_disk",
52        action = clap::ArgAction::SetFalse,
53        default_value_t = true
54    )]
55    pub hide_disk: bool,
56
57    /// Show the preview panel in the TUI
58    #[arg(long, overrides_with = "hide_preview", action = clap::ArgAction::SetTrue)]
59    pub show_preview: bool,
60
61    /// Hide the preview panel in the TUI
62    #[arg(
63        long,
64        overrides_with = "show_preview",
65        action = clap::ArgAction::SetFalse,
66        default_value_t = true
67    )]
68    pub hide_preview: bool,
69
70    /// Show the icon legend panel in the TUI
71    #[arg(long, overrides_with = "hide_legend", action = clap::ArgAction::SetTrue)]
72    pub show_legend: bool,
73
74    /// Hide the icon legend panel in the TUI
75    #[arg(
76        long,
77        overrides_with = "show_legend",
78        action = clap::ArgAction::SetFalse,
79        default_value_t = true
80    )]
81    pub hide_legend: bool,
82
83    /// Show the right panel in the TUI
84    #[arg(long, overrides_with = "hide_right_panel", action = clap::ArgAction::SetTrue)]
85    pub show_right_panel: bool,
86
87    /// Hide the right panel in the TUI
88    #[arg(
89        long,
90        overrides_with = "show_right_panel",
91        action = clap::ArgAction::SetFalse,
92        default_value_t = true
93    )]
94    pub hide_right_panel: bool,
95}
96
97#[derive(ValueEnum, Clone, Copy, PartialEq, Eq, Debug, Hash)]
98pub enum Shell {
99    Fish,
100    Zsh,
101    Bash,
102    #[allow(clippy::enum_variant_names)]
103    NuShell,
104    #[allow(clippy::enum_variant_names)]
105    PowerShell,
106}