Skip to main content

eska_presentation/arguments/build/
import.rs

1//! Shared native command options and help; execution belongs to eska-build.
2
3use super::artifact::{self, PlatformArgs};
4use crate::localization::Localizer;
5use clap::{Args, ValueEnum};
6use std::path::PathBuf;
7
8#[derive(Debug, Args)]
9pub struct ImportArgs {
10    pub file: PathBuf,
11    #[arg(short = 'p', long)]
12    pub project: Option<String>,
13    #[arg(long)]
14    pub force: bool,
15    #[arg(long, conflicts_with = "force")]
16    pub dry_run: bool,
17    #[arg(long, value_enum, default_value_t = Format::Human)]
18    pub format: Format,
19    #[command(flatten)]
20    pub platform: PlatformArgs,
21    #[arg(short, long, action = clap::ArgAction::Help)]
22    pub help: Option<bool>,
23}
24
25#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, ValueEnum)]
26pub enum Format {
27    #[default]
28    Human,
29    Json,
30}
31
32/// Localize every public option while retaining machine-facing flag names.
33pub fn localize(command: clap::Command, localizer: &Localizer) -> clap::Command {
34    artifact::localize(command, localizer)
35        .about(localizer.text("artifact-import-about"))
36        .override_usage(localizer.text("artifact-import-usage"))
37        .help_template(format!(
38            "{{about-with-newline}}\n{}: {{usage}}\n\n{}:\n{{positionals}}\n\n{}:\n{{options}}",
39            localizer.text("cli-usage"),
40            localizer.text("cli-arguments"),
41            localizer.text("cli-options")
42        ))
43        .mut_arg("file", |arg| {
44            arg.help(localizer.text("artifact-file-help"))
45                .value_name(localizer.text("artifact-file-value"))
46        })
47        .mut_arg("project", |arg| {
48            arg.help(localizer.text("artifact-project-help"))
49                .value_name(localizer.text("version-project-value"))
50        })
51        .mut_arg("force", |arg| {
52            arg.help(localizer.text("artifact-force-help"))
53        })
54        .mut_arg("dry_run", |arg| {
55            arg.help(localizer.text("artifact-dry-run-help"))
56        })
57        .mut_arg("format", |arg| {
58            arg.help(localizer.text("build-format-help"))
59        })
60        .mut_arg("help", |arg| arg.help(localizer.text("cli-help")))
61}