voa/cli/
mod.rs

1//! Command line interface handling for the `voa` executable.
2
3mod import;
4mod list;
5
6use clap::{Parser, ValueEnum};
7use clap_verbosity_flag::Verbosity;
8use import::ImportCommand;
9use list::ListCommand;
10
11/// Output format for `voa` commands with data output.
12#[derive(Clone, Debug, Default, strum::Display, ValueEnum)]
13#[strum(serialize_all = "kebab-case")]
14pub enum OutputFormat {
15    /// The JSON output format.
16    Json,
17
18    /// The default text output format.
19    #[default]
20    Text,
21}
22
23/// The top-level command line interface for the `voa` executable.
24#[derive(Debug, Parser)]
25#[command(
26    about = "Command line interface for interacting with VOA hierarchies",
27    author,
28    long_about = None,
29    version,
30)]
31pub struct Cli {
32    /// The verbosity of the command.
33    #[command(flatten)]
34    pub verbosity: Verbosity,
35
36    /// The commands of the `voa` executable.
37    #[command(subcommand)]
38    pub command: Command,
39}
40
41/// A command of the `voa` executable.
42#[derive(Debug, Parser)]
43#[command(about, author, version)]
44pub enum Command {
45    /// The import subcommand.
46    #[command(
47        about = "Import a single verifier into a VOA hierarchy.",
48        long_about = r#"Import a single verifier into a VOA hierarchy.
49
50By default a single verifier is expected on stdin.
51Using the "-i"/"--input" option a specific directory or file can be selected for import instead.
52
53The verifier is written to the user's writable, persistent VOA load path, e.g.:
54
55- "~/.config/voa/": for users with uid >= 1000.
56  Note, that "voa import" respects the XDG Base Directory Specification and the "XDG_CONFIG_HOME" environment variable.
57  The above serves as default example.
58- "/etc/voa/": for users with uid < 1000
59
60When using the "-r"/"--runtime" option, the verifier is written to the user's writable, ephemeral VOA load path instead, e.g.:
61
62- "/run/user/$(id -u)/voa/": for users with uid >= 1000.
63  Note, that "voa import" respects the XDG Base Directory Specification and the "XDG_RUNTIME_DIR" environment variable.
64  The above serves as default example.
65- "/run/voa": for users with uid < 1000
66
67The verifier can be written to another, specific VOA base path using the "-b"/"--base-path" option."#
68    )]
69    Import(ImportCommand),
70
71    /// The list subcommand.
72    #[command(
73        about = "List all verifiers in VOA that match provided identifiers.",
74        long_about = r#"List all verifiers in VOA that match provided identifiers.
75
76By default the "os" and "purpose" identifiers have to be provided for a search.
77Optionally, the "context" and "technology" identifier can be provided for more fine-grained search results.
78"#
79    )]
80    List(ListCommand),
81}