Move clap types to their own module

This commit is contained in:
Alex Page 2023-06-24 16:04:57 -04:00
parent fe98c451f0
commit 8510eb367d
2 changed files with 74 additions and 70 deletions

71
src/bin/xpkey/cli.rs Normal file
View file

@ -0,0 +1,71 @@
use clap::{Args, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, about, version, long_about = None)]
pub struct Cli {
/// Enable verbose output
#[arg(short, long)]
pub verbose: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Clone, Debug)]
pub enum Commands {
/// Show which products/binks can be loaded
List(ListArgs),
/// Generate new product keys
Generate(GenerateArgs),
/// Validate a product key
Validate(ValidateArgs),
/// Generate a phone activation Confirmation ID from an Installation ID
#[command(name = "confid")]
ConfirmationId(ConfirmationIdArgs),
}
#[derive(Args, Clone, Debug)]
pub struct ListArgs {
/// Optional path to load a keys.json file
#[arg(short = 'f', long = "file")]
pub keys_path: Option<String>,
}
#[derive(Args, Clone, Debug)]
pub struct GenerateArgs {
/// Which BINK identifier to use
#[arg(short, long, default_value = "2E")]
pub binkid: String,
/// Channel Identifier to use
#[arg(short = 'c', long = "channel", default_value = "640")]
pub channel_id: u32,
/// Number of keys to generate
#[arg(short = 'n', long = "number", default_value = "1")]
pub num_keys: u64,
/// Optional path to load a keys.json file
#[arg(short = 'f', long = "file")]
pub keys_path: Option<String>,
}
#[derive(Args, Clone, Debug)]
pub struct ValidateArgs {
/// Which BINK identifier to use
#[arg(short, long, default_value = "2E")]
pub binkid: String,
/// Optional path to load a keys.json file
#[arg(short = 'f', long = "file")]
pub keys_path: Option<String>,
/// The Product key to validate
pub key_to_check: String,
}
#[derive(Args, Clone, Debug)]
pub struct ConfirmationIdArgs {
/// The Installation ID used to generate the Confirmation ID
pub instid: String,
}