zoi_cli/cmd/install/
args.rs1use clap::Args;
2use zoi_common::Runnable;
3
4use crate::cli::InstallScope;
5use crate::pkg::plugin::PluginManager;
6
7#[derive(Args, Debug, Clone)]
9pub struct InstallArgs {
10 #[arg(
12 value_name = "ALL_SOURCES",
13 help = "Package identifier (e.g. @repo/name, #git@repo/name, path, or \
14 URL)"
15 )]
16 pub sources: Vec<String>,
17
18 #[arg(long, value_name = "REPO", conflicts_with = "sources")]
21 pub repo: Option<String>,
22
23 #[arg(long)]
25 pub force: bool,
26
27 #[arg(long)]
29 pub all_optional: bool,
30
31 #[arg(long, value_enum, conflicts_with_all = &["local", "global"])]
33 pub scope: Option<InstallScope>,
34
35 #[arg(long, conflicts_with = "global")]
37 pub local: bool,
38
39 #[arg(long)]
41 pub global: bool,
42
43 #[arg(long, conflicts_with = "deps_only")]
45 pub save: bool,
46
47 #[arg(long, conflicts_with_all = &["save", "build_deps_only"])]
50 pub deps_only: bool,
51
52 #[arg(long, conflicts_with_all = &["save", "deps_only"])]
54 pub build_deps_only: bool,
55
56 #[arg(long)]
59 pub r#type: Option<String>,
60
61 #[arg(long)]
63 pub dry_run: bool,
64
65 #[arg(long, short = 'b')]
68 pub build: bool,
69
70 #[arg(long)]
72 pub frozen: bool,
73
74 #[arg(long)]
76 pub explain: bool,
77
78 #[arg(long, requires = "dry_run")]
80 pub plan_json: bool,
81
82 #[arg(long, default_value_t = 3)]
84 pub retry: u32,
85
86 #[arg(long, short)]
88 pub verbose: bool,
89
90 #[arg(long)]
92 pub purl: bool
93}
94
95impl Runnable for InstallArgs {
96 fn run(&self, yes: bool) -> anyhow::Result<()> {
97 let plugin_manager = PluginManager::new()?;
98
99 super::run(
100 &self.sources,
101 self.repo.clone(),
102 self.force,
103 self.all_optional,
104 yes,
105 self.scope,
106 self.local,
107 self.global,
108 self.save,
109 self.deps_only,
110 self.build_deps_only,
111 self.r#type.as_deref(),
112 self.dry_run,
113 Some(&plugin_manager),
114 self.build,
115 self.frozen,
116 self.explain,
117 self.plan_json,
118 self.retry,
119 self.verbose,
120 self.purl,
121 None
122 )
123 }
124}