1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use clap::{
CommandFactory, FromArgMatches, Parser, Subcommand,
builder::{Styles, styling::AnsiColor},
};
use color_eyre::Result;
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(author, name="tmux-deck", about="a tmux session manager and monitoring multi sessions.", version, long_about=None)]
pub struct Cli {
/// Config file (defaults to $XDG_CONFIG_HOME/tmux-deck/config.toml)
#[arg(short, long)]
pub config: Option<PathBuf>,
/// Target pane (e.g., "session:window.pane" or "%123")
#[arg(short, long)]
pub target: Option<String>,
/// Preview refresh interval in milliseconds (overrides the config file)
#[arg(short, long)]
pub interval: Option<u64>,
/// Subcommand (omit to launch the interactive TUI)
#[command(subcommand)]
pub command: Option<Command>,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// Claude Code hook integration: drive treeview markers from Claude's state.
Hook {
#[command(subcommand)]
action: HookAction,
},
}
#[derive(Debug, Subcommand)]
pub enum HookAction {
/// Report a Claude hook event (reads the hook JSON on stdin).
///
/// This is meant to be wired into Claude Code's `settings.json` as a
/// `command` hook. It records the calling pane's Claude state so the
/// tmux-deck TUI can render a per-pane marker.
Report,
/// Install the tmux-deck hooks into Claude Code's settings.json.
Install {
/// Install into the project-local `.claude/settings.json` instead of
/// the user-global `~/.claude/settings.json`.
#[arg(long)]
project: bool,
},
}
impl Cli {
pub fn parse_with_color() -> Result<Self, clap::Error> {
const STYLES: Styles = Styles::styled()
.header(AnsiColor::Green.on_default().bold())
.usage(AnsiColor::Green.on_default().bold())
.literal(AnsiColor::Blue.on_default())
.placeholder(AnsiColor::Cyan.on_default().bold());
let cmd = Self::command().styles(STYLES);
Self::from_arg_matches(&cmd.get_matches())
}
}