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        #[arg(value_hint = ValueHint::FilePath)]
67        config: Option<PathBuf>,
68    },
69    /// Write an initial configuration file.
70    Init {
71        #[arg(long)]
72        #[arg(value_hint = ValueHint::FilePath)]
73        config: Option<PathBuf>,
74    },
75    /// Generate shell completion scripts.
76    Completions {
77        shell: Shell,
78        #[arg(long)]
79        #[arg(value_hint = ValueHint::DirPath)]
80        dir: Option<PathBuf>,
81    },
82    /// Generate man pages.
83    Man {
84        #[arg(long)]
85        #[arg(value_hint = ValueHint::DirPath)]
86        dir: Option<PathBuf>,
87    },
88}