mirror of
https://github.com/eRgo35/ah.git
synced 2026-02-04 21:26:11 +01:00
initial commit plus clap setup
This commit is contained in:
40
src/main.rs
Normal file
40
src/main.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use clap::{Command, Parser, Subcommand, Args};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Option<SubCommands>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum SubCommands {
|
||||
#[command(alias = "i")]
|
||||
Install(PackageArg),
|
||||
#[command(alias = "u")]
|
||||
Upgrade {},
|
||||
#[command(alias = "s")]
|
||||
Sync {},
|
||||
#[command(alias = "r")]
|
||||
Remove(PackageArg),
|
||||
#[command(alias = "f")]
|
||||
Find(PackageArg),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct PackageArg {
|
||||
package: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
match cli.command {
|
||||
Some(SubCommands::Install(arg)) => println!("Installing package: {}", arg.package),
|
||||
Some(SubCommands::Upgrade {}) => todo!(),
|
||||
Some(SubCommands::Sync {}) => todo!(),
|
||||
Some(SubCommands::Remove(arg)) => println!("Removing package: {}", arg.package),
|
||||
Some(SubCommands::Find(arg)) => println!("Looking for package: {}", arg.package),
|
||||
None => println!("No subcommand was used"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user