1mod import;
4mod list;
5mod verify;
6
7use clap::{Parser, ValueEnum};
8use clap_verbosity_flag::Verbosity;
9use import::ImportCommand;
10use list::ListCommand;
11
12use crate::cli::verify::VerifyCommand;
13
14#[derive(Clone, Debug, Default, strum::Display, ValueEnum)]
16#[strum(serialize_all = "kebab-case")]
17pub enum OutputFormat {
18 Json,
20
21 #[default]
23 Text,
24}
25
26#[derive(Debug, Parser)]
28#[command(
29 about = "Command line interface for interacting with VOA hierarchies",
30 author,
31 long_about = None,
32 version,
33)]
34pub struct Cli {
35 #[command(flatten)]
37 pub verbosity: Verbosity,
38
39 #[command(subcommand)]
41 pub command: Command,
42}
43
44#[derive(Debug, Parser)]
46#[command(about, author, version)]
47pub enum Command {
48 #[command(
50 about = "Import a single verifier into a VOA hierarchy.",
51 long_about = r#"Import a single verifier into a VOA hierarchy.
52
53By default a single verifier is expected on stdin.
54Using the "-i"/"--input" option a specific directory or file can be selected for import instead.
55
56The verifier is written to the user's writable, persistent VOA load path, e.g.:
57
58- "~/.config/voa/": for users with uid >= 1000.
59 Note, that "voa import" respects the XDG Base Directory Specification and the "XDG_CONFIG_HOME" environment variable.
60 The above serves as default example.
61- "/etc/voa/": for users with uid < 1000
62
63When using the "-r"/"--runtime" option, the verifier is written to the user's writable, ephemeral VOA load path instead, e.g.:
64
65- "/run/user/$(id -u)/voa/": for users with uid >= 1000.
66 Note, that "voa import" respects the XDG Base Directory Specification and the "XDG_RUNTIME_DIR" environment variable.
67 The above serves as default example.
68- "/run/voa": for users with uid < 1000
69
70The verifier can be written to another, specific VOA base path using the "-b"/"--base-path" option."#
71 )]
72 Import(ImportCommand),
73
74 #[command(
76 about = "List all verifiers in VOA that match provided identifiers.",
77 long_about = r#"List all verifiers in VOA that match provided identifiers.
78
79By default the "os" and "purpose" identifiers have to be provided for a search.
80Optionally, the "context" and "technology" identifier can be provided for more fine-grained search results.
81"#
82 )]
83 List(ListCommand),
84
85 #[command(
87 about = "Verify a file using suitable verifiers and signatures.",
88 long_about = "Verify a file using suitable verifiers and signatures.
89
90Returns a status message on stdout.
91
92Returns a non-zero exit code and an error message on stderr, if the verification of one or more signature files fails."
93 )]
94 Verify(VerifyCommand),
95}