reactive_graph/tooling/update/
args.rs

1use crate::shared::output_format::OutputFormatArgsOptional;
2use crate::tooling::update::commands::UpdateCommands;
3use clap::ArgAction;
4use clap::Parser;
5
6#[derive(Parser, Debug)]
7#[clap(disable_version_flag = true)]
8pub struct UpdateArgs {
9    /// Updates to the nightly release.
10    #[clap(group = "release_tag", short = 'n', long, action=ArgAction::SetTrue, conflicts_with_all = ["latest", "current", "version"])]
11    pub nightly: Option<bool>,
12
13    /// Updates to the latest release.
14    /// Currently, the latest release is the nightly release. This will change in the future.
15    #[clap(group = "release_tag", short = 'l', long, action=ArgAction::SetTrue, conflicts_with_all = ["nightly", "current", "version"])]
16    pub latest: Option<bool>,
17
18    /// Updates to the current release.
19    #[clap(group = "release_tag", short = 'c', long, action=ArgAction::SetTrue, conflicts_with_all = ["nightly", "latest", "version"])]
20    pub current: Option<bool>,
21
22    /// Updates to a specific version.
23    #[clap(group = "release_tag", short = 'v', long, conflicts_with_all = ["nightly", "latest", "current"])]
24    pub version: Option<String>,
25
26    /// Hides the download progress.
27    #[clap(long, action=ArgAction::SetTrue)]
28    pub hide_download_progress: Option<bool>,
29
30    /// Hides the output.
31    #[clap(long, action=ArgAction::SetTrue)]
32    pub hide_output: Option<bool>,
33
34    /// Hides the download progress and the output.
35    #[clap(short = 'q', long, action=ArgAction::SetTrue)]
36    pub quiet: Option<bool>,
37
38    /// Don't ask.
39    #[clap(short = 'y', long, action=ArgAction::SetTrue)]
40    pub no_confirm: Option<bool>,
41
42    #[command(subcommand)]
43    pub commands: Option<UpdateCommands>,
44}
45
46impl UpdateArgs {
47    pub fn show_download_progress(&self) -> bool {
48        !(self.hide_download_progress.unwrap_or_default() || self.quiet.unwrap_or_default())
49    }
50
51    pub fn show_output(&self) -> bool {
52        !(self.hide_output.unwrap_or_default() || self.quiet.unwrap_or_default())
53    }
54
55    pub fn no_confirm(&self) -> bool {
56        self.no_confirm.unwrap_or_default()
57    }
58}
59
60#[derive(Parser, Debug)]
61pub struct UpdateInfoArgs {
62    #[clap(flatten)]
63    pub output_format: OutputFormatArgsOptional,
64}
65
66#[derive(Parser, Debug)]
67pub struct UpdateListArgs {
68    #[clap(flatten)]
69    pub output_format: OutputFormatArgsOptional,
70}