apicurio_cli/commands/
mod.rs1use anyhow::Result;
31use clap::Subcommand;
32
33pub mod add;
34pub mod completions;
35pub mod doctor;
36pub mod init;
37pub mod list;
38pub mod lock;
39pub mod publish;
40pub mod pull;
41pub mod registry;
42pub mod remove;
43pub mod status;
44pub mod update;
45pub mod verify;
46
47#[derive(Subcommand, Debug)]
53pub enum Commands {
54 #[command(about = concat!(
55 "Scaffold a blank config (and empty lock) in a new repo"
56 ))]
57 Init,
58 #[command(
59 about = "Fetch exactly what's in the lock; if no lock, resolve specs ⇒ download ⇒ lock"
60 )]
61 Pull,
62 #[command(
63 about = "Re-resolve semver ranges in config to latest matches; download ⇒ overwrite lock"
64 )]
65 Update,
66 #[command(
67 about = "Add a new dependency entry to the config using format registry/group_id/artifact_id@version"
68 )]
69 Add {
70 #[arg(
71 help = "Dependency identifier in format registry/group_id/artifact_id@version (all parts optional, will prompt for missing)"
72 )]
73 identifier: Option<String>,
74 },
75 #[command(about = "Remove an existing dependency by identifier")]
76 Remove {
77 #[arg(
78 help = "Dependency identifier in format registry/group_id/artifact_id@version (partial matches supported)"
79 )]
80 identifier: String,
81 },
82 #[command(
83 about = "Print all configured deps (spec'd & locked versions), and registries (no network)"
84 )]
85 List,
86 #[command(about = "Compare lock vs. latest matching version in registry; flag outdated deps")]
87 Status,
88 #[command(about = "Re-hash downloaded files & confirm against lockfile hashes")]
89 Verify,
90 #[command(about = "Subcommand: manage global registries file (add/list/remove)")]
91 Registry {
92 #[command(subcommand)]
93 cmd: registry::RegistryCommands,
94 },
95 #[command(
96 about = "Validate config + lock semantics (semver syntax, missing fields, unreachable URLs)"
97 )]
98 Doctor,
99 #[command(about = "Emit shell completion scripts (bash/zsh/fish)")]
100 Completions { shell: String },
101 #[command(about = "Publish to registries")]
102 Publish {
103 #[arg(
104 help = "Specific publish name to publish (if not provided, publishes all configured artifacts)"
105 )]
106 name: Option<String>,
107 },
108 #[command(about = "Update the lockfile based on current dependencies")]
109 Lock,
110}
111
112pub async fn run(cmd: Commands) -> Result<()> {
123 match cmd {
124 Commands::Pull => pull::run().await,
125 Commands::Update => update::run().await,
126 Commands::Init => init::run().await,
127 Commands::Add { identifier } => add::run(identifier).await,
128 Commands::Remove { identifier } => remove::run(identifier).await,
129 Commands::List => list::run().await,
130 Commands::Status => status::run().await,
131 Commands::Verify => verify::run().await,
132 Commands::Registry { cmd } => registry::run(cmd).await,
133 Commands::Doctor => doctor::run().await,
134 Commands::Completions { shell } => completions::run(shell),
135 Commands::Publish { name } => publish::run(name).await,
136 Commands::Lock => lock::run().await,
137 }
138}