1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Copyright 2022-2026 Jochen Kupperschmidt
* License: MIT
*/
use std::path::PathBuf;
use clap::{Parser, Subcommand};
/// Command-line arguments
#[derive(Parser, Debug)]
#[clap(about, author, version)]
pub(crate) struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub(crate) enum Command {
/// Detect button presses and display corresponding key code names
IdentifyButtons {
/// Specify button input device (e.g.
/// `/dev/input/by-id/usb-RANDOM-GAMEPAD-event-joystick`)
#[clap(short = 'd', long = "device")]
device: String,
},
/// Register a Verbleiber client
Register {
/// Specify API hots
#[clap(long = "base-url")]
base_url: String,
/// Supply number of buttons
#[clap(long = "button-count")]
button_count: u8,
/// Specify if device has audio output
#[clap(long = "audio-output")]
audio_output: bool,
/// Disable TLS verification
#[clap(long = "no-tls-verify")]
disable_tls_verification: bool,
},
/// Run the Verbleiber client
Run {
/// Specify configuration filename (e.g. `config.toml`)
#[clap(short = 'c', long = "config")]
config_filename: PathBuf,
},
}
pub(crate) fn parse_cli() -> Cli {
Cli::parse()
}