Skip to main content

podbox/
cli.rs

1use clap::{Parser, ValueEnum};
2use std::path::PathBuf;
3
4#[derive(Parser)]
5#[command(name = "podbox")]
6#[command(version = env!("PODBOX_VERSION"))]
7#[command(about = "Podman-native container environment manager")]
8#[command(
9    after_help = "Common workflow:\n  \
10        podbox create <profile>   Create and start a prebuilt environment\n  \
11        podbox enter              Open a shell in the active container\n  \
12        podbox list               Show managed containers\n  \
13        podbox doctor             Diagnose host and container issues"
14)]
15pub struct Cli {
16    /// Path to the definition TOML file.
17    #[arg(long, short)]
18    pub config: Option<PathBuf>,
19
20    /// Print what would happen without executing.
21    #[arg(long, global = true)]
22    pub dry_run: bool,
23
24    /// Container name to use for commands (overrides config file detection)
25    #[arg(long, short = 'C', global = true)]
26    pub container: Option<String>,
27
28    /// Suppress progress output; errors and data are still printed.
29    #[arg(long, global = true)]
30    pub quiet: bool,
31
32    /// Increase log verbosity (repeatable: -v debug, -vv trace).
33    #[arg(long, short = 'v', action = clap::ArgAction::Count, global = true)]
34    pub verbose: u8,
35
36    #[command(subcommand)]
37    pub command: Command,
38}
39
40mod command;
41
42pub use command::{Command, ExportCommand, ProfileCommand, SnapshotCommand};
43
44#[derive(Debug, Clone, Copy, ValueEnum)]
45pub enum OutputFormat {
46    Text,
47    Json,
48}
49
50#[derive(Debug, Clone, Copy, ValueEnum)]
51pub enum Shell {
52    Bash,
53    Zsh,
54    Fish,
55}
56
57impl From<Shell> for clap_complete::shells::Shell {
58    fn from(s: Shell) -> Self {
59        match s {
60            Shell::Bash => clap_complete::shells::Shell::Bash,
61            Shell::Zsh => clap_complete::shells::Shell::Zsh,
62            Shell::Fish => clap_complete::shells::Shell::Fish,
63        }
64    }
65}