rustsec_admin/
commands.rs

1//! `rustsec-admin` CLI subcommands
2
3mod assign_id;
4mod lint;
5mod list_affected_versions;
6mod osv;
7mod sync;
8mod version;
9mod web;
10
11use self::{
12    assign_id::AssignIdCmd, lint::LintCmd, list_affected_versions::ListAffectedVersionsCmd,
13    osv::OsvCmd, sync::SyncCmd, version::VersionCmd, web::WebCmd,
14};
15use crate::config::AppConfig;
16use abscissa_core::{Command, Configurable, Runnable};
17use clap::Parser;
18use std::path::PathBuf;
19
20/// `rustsec-admin` CLI subcommands
21#[derive(Command, Debug, Parser, Runnable)]
22pub enum AdminSubCmd {
23    /// The `lint` subcommand
24    #[command(about = "lint Advisory DB and ensure is well-formed")]
25    Lint(LintCmd),
26
27    /// The `sync` subcommand
28    #[clap(about = "synchronize information from external sources (osv.dev, NVD, etc.)")]
29    Sync(SyncCmd),
30
31    /// The `web` subcommand
32    #[command(about = "render advisory Markdown files for the rustsec.org web site")]
33    Web(WebCmd),
34
35    /// The `version` subcommand
36    #[command(about = "display version information")]
37    Version(VersionCmd),
38
39    /// The `assign-id` subcommand
40    #[command(about = "assigning RUSTSEC ids to new vulnerabilities")]
41    AssignId(AssignIdCmd),
42
43    /// The `osv` subcommand
44    #[command(about = "export advisories to OSV format")]
45    Osv(OsvCmd),
46
47    /// The `version` subcommand
48    #[command(about = "list affected crate versions")]
49    ListAffectedVersions(ListAffectedVersionsCmd),
50}
51
52/// `rustsec-admin` CLI commands
53#[derive(Command, Debug, Parser)]
54#[command(author, version, about)]
55pub struct AdminCmd {
56    #[command(subcommand)]
57    cmd: AdminSubCmd,
58
59    /// Increase verbosity setting
60    #[arg(short = 'v', long, help = "Increase verbosity")]
61    pub verbose: bool,
62}
63
64impl Runnable for AdminCmd {
65    fn run(&self) {
66        self.cmd.run()
67    }
68}
69
70impl Configurable<AppConfig> for AdminCmd {
71    /// Location of the configuration file
72    fn config_path(&self) -> Option<PathBuf> {
73        None
74    }
75}