use crate::cli::formats::LogFormat;
use crate::cli::Commands;
use clap::Parser;
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(
author,
version,
about = "A CLI tool to serve as swiss-army knife for your operations on Kubernetes pods and nodes",
long_about = None
)]
pub struct Args {
#[arg(long = "kubeconfig", global = true)]
pub kubeconfig: Option<PathBuf>,
#[arg(short = 'v', long = "verbose", global = true, action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(
long = "log-format",
default_value = "plain",
global = true,
requires = "verbose"
)]
pub log_format: LogFormat,
#[command(subcommand)]
pub command: Commands,
}
impl Args {
pub fn get_kubeconfig_path(&self) -> Option<PathBuf> {
self.kubeconfig
.clone()
.or_else(|| std::env::var("KUBECONFIG").ok().map(PathBuf::from))
}
}