Skip to main content

eska_presentation/arguments/build/
patch.rs

1//! Shared native command options and help; execution belongs to eska-build.
2
3use crate::localization::Localizer;
4use clap::{Args, ValueEnum};
5use std::path::PathBuf;
6
7#[derive(Debug, Args)]
8pub struct PatchArgs {
9    #[arg(long)]
10    pub base: Option<String>,
11    #[arg(long)]
12    pub output: Option<PathBuf>,
13    #[arg(long)]
14    pub dry_run: bool,
15    #[arg(long)]
16    pub ibcmd: Option<PathBuf>,
17    #[arg(long)]
18    pub platform_arch: Option<String>,
19    #[arg(long)]
20    pub distrobox: Option<String>,
21    #[arg(long)]
22    pub platform_version: Option<String>,
23    #[arg(long, value_enum, default_value_t = Format::Human)]
24    pub format: Format,
25    #[arg(short, long, action = clap::ArgAction::Help)]
26    pub help: Option<bool>,
27}
28
29#[derive(Clone, Copy, Debug, ValueEnum)]
30pub enum Format {
31    Human,
32    Json,
33}
34
35/// Localize every new help field without translating argument names or machine values.
36pub fn localize(mut command: clap::Command, localizer: &Localizer) -> clap::Command {
37    command = command.about(localizer.text("patch-about"));
38    for name in [
39        "base",
40        "output",
41        "dry_run",
42        "ibcmd",
43        "platform_arch",
44        "distrobox",
45        "platform_version",
46        "format",
47    ] {
48        command = command.mut_arg(name, |arg| {
49            arg.help(localizer.text(&format!("patch-help-{}", name.replace('_', "-"))))
50        });
51    }
52    command.mut_arg("help", |arg| arg.help(localizer.text("cli-help")))
53}