Skip to content

Commit

Permalink
properly document CLI options
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Sep 25, 2024
1 parent ede5852 commit 1866bbc
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<PathBuf>,

#[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<SkipPhases>,

#[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<String>,

#[arg(long, short = 'O')]
Expand All @@ -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,
}

Expand Down Expand Up @@ -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()?;
Expand Down

0 comments on commit 1866bbc

Please sign in to comment.