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)]
26 pub force: bool,
27
28 #[arg(long)]
30 pub all_optional: bool,
31
32 #[arg(long, value_enum, conflicts_with_all = &["local", "global"])]
34 pub scope: Option<InstallScope>,
35
36 #[arg(long, conflicts_with = "global")]
38 pub local: bool,
39
40 #[arg(long)]
42 pub global: bool,
43
44 #[arg(long, conflicts_with = "deps_only")]
46 pub save: bool,
47
48 #[arg(long, conflicts_with_all = &["save", "build_deps_only"])]
51 pub deps_only: bool,
52
53 #[arg(long, conflicts_with_all = &["save", "deps_only"])]
55 pub build_deps_only: bool,
56
57 #[arg(long)]
60 pub r#type: Option<String>,
61
62 #[arg(long)]
64 pub dry_run: bool,
65
66 #[arg(long, short = 'b')]
69 pub build: bool,
70
71 #[arg(long)]
73 pub frozen: bool,
74
75 #[arg(long)]
77 pub explain: bool,
78
79 #[arg(long, requires = "dry_run")]
81 pub plan_json: bool,
82
83 #[arg(long, default_value_t = 3)]
85 pub retry: u32,
86
87 #[arg(long, short)]
89 pub verbose: bool,
90
91 #[arg(long)]
93 pub purl: bool
94}
95
96impl Runnable for InstallArgs {
97 fn run(&self, yes: bool) -> anyhow::Result<()> {
98 let plugin_manager = PluginManager::new()?;
99
100 super::run(
101 &self.sources,
102 self.repo.clone(),
103 self.force,
104 self.all_optional,
105 yes,
106 self.scope,
107 self.local,
108 self.global,
109 self.save,
110 self.deps_only,
111 self.build_deps_only,
112 self.r#type.as_deref(),
113 self.dry_run,
114 Some(&plugin_manager),
115 self.build,
116 self.frozen,
117 self.explain,
118 self.plan_json,
119 self.retry,
120 self.verbose,
121 self.purl,
122 None
123 )
124 }
125}