1use clap::Args;
2use std::path::PathBuf;
3#[derive(Args, Debug)]
6pub struct PublishArgs {
7 #[clap(value_parser)]
9 pub action: String,
10
11 #[clap(long)]
13 pub registry: Option<String>,
14
15 #[clap(long)]
17 pub token: Option<String>,
18
19 #[clap(long)]
21 pub dry_run: bool,
22
23 #[clap(long)]
25 pub verbose: bool,
26
27 #[clap(long)]
29 pub quiet: bool,
30
31 #[clap(long)]
33 pub input: Option<PathBuf>,
34
35 #[clap(long)]
37 pub key: Option<String>,
38
39 #[clap(long)]
41 pub output: Option<PathBuf>,
42
43 #[clap(long)]
45 pub verify: bool,
46
47 #[clap(long)]
49 pub format: Option<String>,
50
51 #[clap(long)]
53 pub include_deps: bool,
54}
55
56pub fn run(args: PublishArgs) -> anyhow::Result<()> {
57 match args.action.as_str() {
58 "publish" => {
59 crate::mds::publish::publish_project(
60 args.registry,
61 args.token,
62 args.dry_run,
63 args.verbose,
64 )?;
65 }
66 "sign" => {
67 let input = args.input.clone().ok_or_else(|| anyhow::anyhow!("--input is required for sign action"))?;
68 crate::mds::publish::sign_binary(
69 input,
70 args.key.clone(),
71 args.output.clone(),
72 args.verify,
73 args.verbose,
74 )?;
75 }
76 "export" => {
77 let format = args.format.clone().ok_or_else(|| anyhow::anyhow!("--format is required for export action"))?;
78 crate::mds::publish::export_project(
79 format,
80 args.output.clone(),
81 args.include_deps,
82 args.verbose,
83 )?;
84 }
85 _ => {
86 return Err(anyhow::anyhow!("Unknown publish action: {}", args.action));
87 }
88 }
89 Ok(())
90}