diff --git a/src/cli.rs b/src/cli.rs index f7cb96f..d765f43 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use clap::{value_parser, Parser}; +use clap::{value_parser, Parser, ValueEnum}; use color_eyre::Result; use serde_derive::{Deserialize, Serialize}; use tracing::trace; @@ -15,19 +15,31 @@ use crate::{builder::KatsuBuilder, config::Manifest}; #[derive(Parser, Debug)] #[command(author, version, about)] pub struct KatsuCli { + /// Enable verbose output #[arg(short, long, default_value = "false")] verbose: bool, /// Config file location config: Option, - #[arg(short, long, value_parser = value_parser!(OutputFormat))] + #[arg(short, long)] + #[arg(value_enum)] + /// Format of the artifact Katsu should output output: OutputFormat, - #[arg(short, long,env = "KATSU_SKIP_PHASES", value_parser = value_parser!(SkipPhases), default_value = "")] - skip_phases: SkipPhases, + + /// Skip individual phases + /// + /// By default, no phases are skipped for any format + /// + #[arg(short, long,env = "KATSU_SKIP_PHASES", value_parser = value_parser!(SkipPhases))] + #[arg()] + skip_phases: Option, #[arg(long)] - /// Override architecture to build for + /// Override architecture to build for, makes use of DNF's `--arch` option + /// and chroots using userspace QEMU emulation if necessary + /// + /// By default, Katsu will build for the host architecture arch: Option, #[arg(long, short = 'O')] @@ -50,11 +62,16 @@ impl From<&str> for SkipPhases { } } -#[derive(Serialize, Deserialize, Clone, Copy, Debug)] +#[derive(Serialize, Deserialize, Clone, Copy, Debug, ValueEnum)] pub enum OutputFormat { + /// Creates a hybrid, bootable ISO-9660 image (with El Torito extensions) Iso, + /// Creates a raw disk image that can either be flashed to a block device, + /// loopback mounted, or used as a virtual disk image DiskImage, + /// Install to a block device directly Device, + /// Simply copies the root tree to a directory Folder, } @@ -101,7 +118,7 @@ pub fn parse(cli: KatsuCli) -> Result<()> { trace!(?manifest, "Loaded manifest"); - let builder = KatsuBuilder::new(manifest, cli.output, cli.skip_phases)?; + let builder = KatsuBuilder::new(manifest, cli.output, cli.skip_phases.unwrap_or_default())?; tracing::info!("Building image"); builder.build()?;