Skip to main content

signstar_request_signature/
cli.rs

1//! Command line interface.
2
3use std::path::PathBuf;
4
5use clap::Parser;
6use clap_verbosity_flag::Verbosity;
7
8use crate::ssh::client::ConnectConfig;
9
10/// Command line arguments for signing.
11#[derive(Debug, Parser)]
12pub struct Cli {
13    /// Global processing log verbosity.
14    #[command(flatten)]
15    pub verbosity: Verbosity,
16
17    /// Command to be executed.
18    #[command(subcommand)]
19    pub command: Command,
20}
21
22/// Command line arguments for signing.
23#[derive(Debug, Parser)]
24pub enum Command {
25    /// Prepare signing request for a file.
26    Prepare(PrepareCommand),
27
28    /// Send signing request over SSH.
29    Send(SendCommand),
30}
31
32/// Signing request input parameters.
33#[derive(Debug, Parser)]
34pub struct PrepareCommand {
35    /// The path to a file being signed
36    #[arg(env = "SIGNSTAR_REQUEST_FILE")]
37    pub input: PathBuf,
38}
39
40/// Sending signing request input parameters.
41#[derive(Debug, Parser)]
42pub struct SendCommand {
43    /// Configuration file to use.
44    #[arg(long, env = "SIGNSTAR_REQUEST_CONFIG", long_help = format!("Configuration file to use.
45
46If unspecified, one of the following configuration files is used if it exists, in the following order:
47
48{paths}", paths = ConnectConfig::CONFIG_ORDER.iter().map(|path| format!("- {path}")).collect::<Vec<_>>().join("\n")))]
49    pub config: Option<PathBuf>,
50
51    /// The user to use for connecting.
52    ///
53    /// If this option is set only connections with matching username are considered.
54    #[arg(long)]
55    pub user: Option<String>,
56
57    /// The path to a file being signed
58    #[arg(env = "SIGNSTAR_REQUEST_FILE")]
59    pub input: PathBuf,
60}