refactor: rename project name from underline to dash
This commit is contained in:
116
wfassoc-exec/src/cli.rs
Normal file
116
wfassoc-exec/src/cli.rs
Normal file
@@ -0,0 +1,116 @@
|
||||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
|
||||
// region: Clap Declaration
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, ValueEnum)]
|
||||
enum Target {
|
||||
#[value(name = "user")]
|
||||
User,
|
||||
#[value(name = "system")]
|
||||
System,
|
||||
}
|
||||
|
||||
/// Simple program to manage Windows file associations
|
||||
#[derive(Parser)]
|
||||
#[command(name = "Windows File Association Operator", version, about)]
|
||||
struct Cli {
|
||||
/// The TOML manifest file representing the complete program
|
||||
#[arg(
|
||||
short = 'm',
|
||||
long = "manifest",
|
||||
value_name = "PROG_MANIFEST",
|
||||
required = true
|
||||
)]
|
||||
manifest_file: String,
|
||||
#[command(subcommand)]
|
||||
command: CliCommands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum CliCommands {
|
||||
/// Register the program
|
||||
#[command(name = "register")]
|
||||
#[command(about = "Register application with given manifest and scope.")]
|
||||
Register {
|
||||
/// The scope where wfassoc operate
|
||||
#[arg(short = 't', long = "target", value_name = "TARGET", required = true, value_enum, default_value_t = Target::User)]
|
||||
target: Target,
|
||||
},
|
||||
/// Unregister the program
|
||||
#[command(name = "unregister")]
|
||||
#[command(about = "Unregister application with given manifest and scope.")]
|
||||
Unregister {
|
||||
/// The scope where wfassoc operate
|
||||
#[arg(short = 't', long = "target", value_name = "TARGET", required = true, value_enum, default_value_t = Target::User)]
|
||||
target: Target,
|
||||
},
|
||||
/// Fetch current registration status
|
||||
#[command(name = "status")]
|
||||
#[command(
|
||||
about = "Fetch the status of registration for given manifest represented application."
|
||||
)]
|
||||
Status,
|
||||
#[command(name = "ext")]
|
||||
#[command(about = "File extension related operations according to given program manifest.")]
|
||||
Ext {
|
||||
#[command(subcommand)]
|
||||
command: CliExtCommands,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum CliExtCommands {
|
||||
#[command(name = "link")]
|
||||
#[command(about = "Link user given file extension to the program declared in manifest file.")]
|
||||
Link {
|
||||
// The file extensions used for this operation. Specify * for all file extension.
|
||||
#[arg(required = true, value_name = "EXTS", num_args = 1..)]
|
||||
exts: Vec<String>,
|
||||
},
|
||||
#[command(name = "unlink")]
|
||||
#[command(
|
||||
about = "Unlink user given file extension from the program declared in manifest file."
|
||||
)]
|
||||
Unlink {
|
||||
// The file extensions used for this operation. Specify * for all file extension.
|
||||
#[arg(required = true, value_name = "EXTS", num_args = 1..)]
|
||||
exts: Vec<String>,
|
||||
},
|
||||
#[command(name = "list")]
|
||||
#[command(
|
||||
about = "List the association status for all extensions declared in given program manifest."
|
||||
)]
|
||||
List,
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region: Exposed Type
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Request {
|
||||
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RequestCommand {
|
||||
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RequestExtCommand {
|
||||
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
///
|
||||
///
|
||||
/// Please note that if there is "help" or "version" command matched,
|
||||
/// or any command line parse error occurs,
|
||||
/// this function will order program exit immediately.
|
||||
/// This is the mechanism of clap crate.
|
||||
pub fn parse() -> Request {
|
||||
let cli = Cli::parse();
|
||||
todo!()
|
||||
}
|
||||
Reference in New Issue
Block a user