mod bundle;
pub mod extract;
pub mod pack;
use crate::options::{cli_options, CliOptions, ColorsArg};
use crate::VERSION;
use bpaf::Bpaf;
use std::ffi::OsString;
#[derive(Debug, Clone, Bpaf)]
#[bpaf(options, version(VERSION))]
pub enum CliCommand {
#[bpaf(command)]
Pack {
#[bpaf(external(cli_options), hide_usage)]
cli_options: CliOptions,
#[bpaf(short('o'), long("outfile"), argument("PATH"), optional)]
outfile: Option<String>,
#[bpaf(long("truncate"), switch)]
truncate: bool,
#[bpaf(positional("PATH"))]
dir: OsString,
},
#[bpaf(command)]
Extract {
#[bpaf(external(cli_options), hide_usage)]
cli_options: CliOptions,
#[bpaf(long("dry-run"), switch)]
dry_run: bool,
#[bpaf(short('o'), long("outdir"), argument("PATH"), optional)]
outdir: Option<String>,
#[bpaf(positional("PATH"))]
file: OsString,
},
}
impl CliCommand {
const fn cli_options(&self) -> Option<&CliOptions> {
match self {
CliCommand::Pack { cli_options, .. } | CliCommand::Extract { cli_options, .. } => {
Some(cli_options)
}
}
}
pub const fn get_color(&self) -> Option<&ColorsArg> {
match self.cli_options() {
Some(cli_options) => cli_options.colors.as_ref(),
None => None,
}
}
}