global: snapshot

This commit is contained in:
nym21
2025-03-01 15:22:34 +01:00
parent 1b93ccf608
commit 6d7ff38cf2
40 changed files with 936 additions and 768 deletions
-2
View File
@@ -1,2 +0,0 @@
#![doc = include_str!("../README.md")]
+39 -2
View File
@@ -1,3 +1,40 @@
fn main() {
println!("Hello, world!");
use clap::{Args, Parser, Subcommand};
#[derive(Parser)]
#[command(version, about)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Run(RunArgs),
Query(QueryArgs),
}
#[derive(Args)]
struct RunArgs {
name: Option<String>,
}
#[derive(Args)]
struct QueryArgs {
name: Option<String>,
}
fn main() {
let cli = Cli::parse();
// You can check for the existence of subcommands, and if found use their
// matches just as you would the top level cmd
match &cli.command {
Commands::Run(name) => {
println!("'myapp add' was used, name is: {:?}", name.name);
}
Commands::Query(name) => {
println!("'myapp add' was used, name is: {:?}", name.name);
}
}
}