Skip to main content

smux/
cli.rs

1use std::path::PathBuf;
2
3use clap::CommandFactory;
4use clap::{Parser, Subcommand, ValueHint};
5use clap_complete::Shell;
6
7#[derive(Debug, Parser)]
8#[command(name = "smux")]
9#[command(version)]
10#[command(arg_required_else_help = true)]
11#[command(about = "Small Rust CLI for tmux session selection and creation")]
12pub struct Cli {
13    #[command(subcommand)]
14    pub command: Commands,
15}
16
17impl Cli {
18    pub fn command() -> clap::Command {
19        <Self as CommandFactory>::command()
20    }
21}
22
23#[derive(Debug, Subcommand)]
24pub enum Commands {
25    /// Open the unified tmux-session and zoxide-directory selector.
26    Select {
27        #[arg(long)]
28        choose_template: bool,
29        #[arg(long)]
30        no_project_detect: bool,
31        #[arg(long)]
32        #[arg(value_hint = ValueHint::FilePath)]
33        config: Option<PathBuf>,
34    },
35    /// Create or reuse a tmux session for a directory.
36    Connect {
37        #[arg(value_hint = ValueHint::DirPath)]
38        path: PathBuf,
39        #[arg(long)]
40        template: Option<String>,
41        #[arg(long)]
42        session_name: Option<String>,
43        #[arg(long)]
44        #[arg(value_hint = ValueHint::FilePath)]
45        config: Option<PathBuf>,
46    },
47    /// Switch to or attach an existing tmux session.
48    Switch { session: String },
49    /// Print current tmux session names.
50    ListSessions,
51    /// Print configured template names.
52    ListTemplates {
53        #[arg(long)]
54        #[arg(value_hint = ValueHint::FilePath)]
55        config: Option<PathBuf>,
56    },
57    /// Print configured project entries.
58    ListProjects {
59        #[arg(long)]
60        #[arg(value_hint = ValueHint::FilePath)]
61        config: Option<PathBuf>,
62    },
63    /// Validate runtime dependencies and basic environment state.
64    Doctor {
65        #[arg(long)]
66        fix: bool,
67        #[arg(long)]
68        #[arg(value_hint = ValueHint::FilePath)]
69        config: Option<PathBuf>,
70    },
71    /// Capture a tmux session as a project file.
72    SaveProject {
73        name: String,
74        #[arg(long)]
75        session: Option<String>,
76        #[arg(long)]
77        #[arg(value_hint = ValueHint::DirPath)]
78        path: Option<PathBuf>,
79        #[arg(long)]
80        stdout: bool,
81        #[arg(long)]
82        force: bool,
83        #[arg(long)]
84        #[arg(value_hint = ValueHint::FilePath)]
85        config: Option<PathBuf>,
86    },
87    /// Write an initial configuration file.
88    Init {
89        #[arg(long)]
90        #[arg(value_hint = ValueHint::FilePath)]
91        config: Option<PathBuf>,
92    },
93    /// Generate shell completion scripts.
94    Completions {
95        shell: Shell,
96        #[arg(long)]
97        #[arg(value_hint = ValueHint::DirPath)]
98        dir: Option<PathBuf>,
99    },
100    /// Generate man pages.
101    Man {
102        #[arg(long)]
103        #[arg(value_hint = ValueHint::DirPath)]
104        dir: Option<PathBuf>,
105    },
106}