use std::path::PathBuf;
use clap::{Parser, Subcommand, ValueHint};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None, after_long_help = GLOBAL_EXAMPLES)]
pub struct Args {
#[arg(
short = 'C',
long,
value_name = "DIR",
env = "VORTIX_CONFIG_DIR",
global = true,
value_hint = ValueHint::DirPath,
)]
pub config_dir: Option<PathBuf>,
#[arg(short = 'j', long, global = true)]
pub json: bool,
#[arg(short = 'q', long, global = true)]
pub quiet: bool,
#[arg(short = 'v', long, global = true)]
pub verbose: bool,
#[command(subcommand)]
pub command: Option<Commands>,
}
const GLOBAL_EXAMPLES: &str = "\
GLOBAL FLAGS:
-j, --json Machine-readable JSON output
-q, --quiet Suppress all output except errors
-v, --verbose Verbose debug output
-C, --config-dir Override config directory
ENVIRONMENT VARIABLES:
VORTIX_CONFIG_DIR Override config directory
EXIT CODES:
0 Success
1 General error
2 Permission denied (needs sudo)
3 Not found (profile doesn't exist)
4 State conflict (already connected/disconnected)
5 Missing dependency (wg-quick, openvpn)
6 Timeout";
#[derive(Subcommand, Debug)]
pub enum Commands {
#[command(visible_alias = "connect")]
Up {
#[arg(value_hint = ValueHint::Other)]
profile: Option<String>,
#[arg(long, default_value = "20", value_name = "SECS")]
timeout: u64,
},
#[command(visible_alias = "disconnect")]
Down {
#[arg(short, long)]
force: bool,
},
Reconnect,
Status {
#[arg(short, long)]
watch: bool,
#[arg(long, default_value = "2", value_name = "SECS")]
interval: u64,
#[arg(short, long)]
brief: bool,
},
#[command(visible_alias = "ls")]
List {
#[arg(short, long, value_name = "FIELD")]
sort: Option<String>,
#[arg(short, long)]
reverse: bool,
#[arg(short, long, value_name = "PROTO")]
protocol: Option<String>,
#[arg(short = '1', long)]
names_only: bool,
},
Import {
#[arg(value_hint = ValueHint::AnyPath)]
file: String,
},
Show {
#[arg(value_hint = ValueHint::Other)]
profile: String,
#[arg(long)]
raw: bool,
},
#[command(visible_alias = "rm")]
Delete {
#[arg(value_hint = ValueHint::Other)]
profile: String,
#[arg(short, long)]
yes: bool,
},
#[command(visible_alias = "mv")]
Rename {
old: String,
new: String,
},
#[command(name = "killswitch")]
KillSwitch {
mode: Option<String>,
},
ReleaseKillSwitch,
Info,
Update,
Report,
Completions {
shell: clap_complete::Shell,
},
}