voa 0.7.3

Command line interface and library for interacting with the File Hierarchy for the Verification of OS Artifacts (VOA)
Documentation
//! The `voa import` subcommand.

use std::path::PathBuf;

use clap::Parser;
use voa_core::identifiers::{Context, Os, Purpose, Technology};

use crate::utils::DirOrFile;

#[derive(Debug, Parser)]
pub struct ImportCommand {
    #[arg(env = "VOA_IMPORT_OS", help = "The OS to import for.")]
    pub os: Os,

    #[arg(env = "VOA_IMPORT_PURPOSE", help = "The purpose to import for.")]
    pub purpose: Purpose,

    #[arg(
        env = "VOA_IMPORT_CONTEXT",
        help = "The context to import for.",
        long,
        long_help = r#"The context to import for.

If not specified, defaults to "default"."#,
        short
    )]
    pub context: Option<Context>,

    #[arg(
        env = "VOA_IMPORT_TECHNOLOGY",
        help = "The technology to import for.",
        long_help = r#"The technology to import for.

Currently only "openpgp" is supported."#
    )]
    pub technology: Technology,

    #[arg(
        env = "VOA_IMPORT_INPUT",
        help = "The directory or file to import from.",
        long,
        long_help = r#"The directory or file to import from.

If a directory is provided and the selected technology is "openpgp" it must either contain:

- OpenPGP packet files,
- or a directory structure with OpenPGP packet files, compatible with the "archlinux-keyring" format.

If no directory or file is provided, stdin is used instead."#,
        short
    )]
    pub input: Option<DirOrFile>,

    #[arg(
        env = "VOA_IMPORT_BASE_PATH",
        group = "custom-output",
        help = "The VOA base path to write to.",
        long,
        long_help = r#"The VOA base path to write to.

If not specified, the user's writable, persistent VOA load path is chosen, e.g.:

- "~/.config/voa/": for users with uid >= 1000
- "/etc/voa/": for users with uid < 1000

To use the user's writable, ephemeral VOA load path if no directory is provided, pass the "-r"/"--runtime" option to the command.
In this case the writable, ephemeral VOA load path is chosen, e.g.:

- "/run/user/$(id -u)/voa/": for users with uid >= 1000
- "/run/voa": for users with uid < 1000"#,
        short
    )]
    pub base_path: Option<PathBuf>,

    #[arg(
        conflicts_with = "custom-output",
        env = "VOA_IMPORT_RUNTIME",
        help = "Whether to import to the runtime directory.",
        long,
        long_help = r#"Whether to import to the runtime directory.

Instructs the import mechanism to use the user's writable, ephemeral VOA load path, e.g.:

- "/run/user/$(id -u)/voa/": for users with uid >= 1000
- "/run/voa": for users with uid < 1000

By 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.:

- "~/.config/voa/": for users with uid >= 1000
- "/etc/voa/": for users with uid < 1000

Note, that this option cannot be selected together with "-b"/"--base-path"."#,
        short
    )]
    pub runtime: bool,
}