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