voa/cli/
import.rs

1//! The `voa import` subcommand.
2
3use std::path::PathBuf;
4
5use clap::Parser;
6use voa_core::identifiers::{Context, Os, Purpose, Technology};
7
8use crate::utils::DirOrFile;
9
10#[derive(Debug, Parser)]
11pub struct ImportCommand {
12    #[arg(env = "VOA_IMPORT_OS", help = "The OS to import for.")]
13    pub os: Os,
14
15    #[arg(env = "VOA_IMPORT_PURPOSE", help = "The purpose to import for.")]
16    pub purpose: Purpose,
17
18    #[arg(
19        env = "VOA_IMPORT_CONTEXT",
20        help = "The context to import for.",
21        long,
22        long_help = r#"The context to import for.
23
24If not specified, defaults to "default"."#,
25        short
26    )]
27    pub context: Option<Context>,
28
29    #[arg(
30        env = "VOA_IMPORT_TECHNOLOGY",
31        help = "The technology to import for.",
32        long_help = r#"The technology to import for.
33
34Currently only "openpgp" is supported."#
35    )]
36    pub technology: Technology,
37
38    #[arg(
39        env = "VOA_IMPORT_INPUT",
40        help = "The directory or file to import from.",
41        long,
42        long_help = r#"The directory or file to import from.
43
44If a directory is provided and the selected technology is "openpgp" it must either contain:
45
46- OpenPGP packet files,
47- or a directory structure with OpenPGP packet files, compatible with the "archlinux-keyring" format.
48
49If no directory or file is provided, stdin is used instead."#,
50        short
51    )]
52    pub input: Option<DirOrFile>,
53
54    #[arg(
55        env = "VOA_IMPORT_BASE_PATH",
56        group = "custom-output",
57        help = "The VOA base path to write to.",
58        long,
59        long_help = r#"The VOA base path to write to.
60
61If not specified, the user's writable, persistent VOA load path is chosen, e.g.:
62
63- "~/.config/voa/": for users with uid >= 1000
64- "/etc/voa/": for users with uid < 1000
65
66To use the user's writable, ephemeral VOA load path if no directory is provided, pass the "-r"/"--runtime" option to the command.
67In this case the writable, ephemeral VOA load path is chosen, e.g.:
68
69- "/run/user/$(id -u)/voa/": for users with uid >= 1000
70- "/run/voa": for users with uid < 1000"#,
71        short
72    )]
73    pub base_path: Option<PathBuf>,
74
75    #[arg(
76        conflicts_with = "custom-output",
77        env = "VOA_IMPORT_RUNTIME",
78        help = "Whether to import to the runtime directory.",
79        long,
80        long_help = r#"Whether to import to the runtime directory.
81
82Instructs the import mechanism to use the user's writable, ephemeral VOA load path, e.g.:
83
84- "/run/user/$(id -u)/voa/": for users with uid >= 1000
85- "/run/voa": for users with uid < 1000
86
87By default, if this option and the "-b"/"--base-path" options are not provided, a verifier is imported to the writable, persistent VOA load path of the user, e.g.:
88
89- "~/.config/voa/": for users with uid >= 1000
90- "/etc/voa/": for users with uid < 1000
91
92Note, that this option cannot be selected together with "-b"/"--base-path"."#,
93        short
94    )]
95    pub runtime: bool,
96}