Skip to main content

eska_presentation/arguments/project/
doctor.rs

1//! Shared project command options and help; metadata and transactions stay with their owner.
2
3use crate::localization::Localizer;
4use clap::{Args, ValueEnum};
5use std::path::PathBuf;
6
7#[derive(Debug, Args)]
8pub struct DoctorArgs {
9    #[arg(long)]
10    pub ibcmd: Option<PathBuf>,
11
12    #[arg(long)]
13    pub platform_arch: Option<String>,
14
15    #[arg(long)]
16    pub distrobox: Option<String>,
17
18    #[arg(long, value_enum, default_value_t = OutputFormat::Human)]
19    pub format: OutputFormat,
20
21    #[arg(short = 'p', long)]
22    pub project: Vec<String>,
23
24    #[arg(long)]
25    pub workspace: bool,
26
27    #[arg(short, long, action = clap::ArgAction::Help)]
28    pub help: Option<bool>,
29}
30
31#[derive(Clone, Copy, Debug, Default, ValueEnum)]
32pub enum OutputFormat {
33    #[default]
34    Human,
35    Json,
36}
37
38/// Localize command help without changing option names or machine-facing values.
39pub fn localize(command: clap::Command, localizer: &Localizer) -> clap::Command {
40    command
41        .about(localizer.text("doctor-about"))
42        .override_usage(localizer.text("doctor-usage"))
43        .mut_arg("ibcmd", |arg| {
44            arg.help(localizer.text("build-ibcmd-help"))
45                .value_name(localizer.text("build-ibcmd-value"))
46        })
47        .mut_arg("platform_arch", |arg| {
48            arg.help(localizer.text("build-arch-help"))
49                .value_name(localizer.text("build-arch-value"))
50        })
51        .mut_arg("distrobox", |arg| {
52            arg.help(localizer.text("build-distrobox-help"))
53                .value_name(localizer.text("build-distrobox-value"))
54        })
55        .mut_arg("format", |arg| {
56            arg.help(localizer.text("doctor-format-help"))
57                .value_name(localizer.text("doctor-format-value"))
58        })
59        .mut_arg("project", |arg| {
60            arg.help(localizer.text("doctor-project-help"))
61                .value_name(localizer.text("doctor-project-value"))
62        })
63        .mut_arg("workspace", |arg| {
64            arg.help(localizer.text("doctor-workspace-help"))
65        })
66        .mut_arg("help", |arg| arg.help(localizer.text("cli-help")))
67}