Use a rust crate for demo

This commit is contained in:
Sridhar Ratnakumar 2023-06-26 15:24:39 -04:00
parent 9f448de544
commit 31c259271d
3 changed files with 48 additions and 88 deletions

110
Cargo.lock generated
View file

@ -1,113 +1,73 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "ansi_term" name = "argh"
version = "0.11.0" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" checksum = "ab257697eb9496bf75526f0217b5ed64636a9cfafa78b8365c71bd283fcef93e"
dependencies = [ dependencies = [
"winapi", "argh_derive",
"argh_shared",
] ]
[[package]] [[package]]
name = "atty" name = "argh_derive"
version = "0.2.14" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" checksum = "b382dbd3288e053331f03399e1db106c9fb0d8562ad62cb04859ae926f324fa6"
dependencies = [ dependencies = [
"hermit-abi", "argh_shared",
"libc", "proc-macro2",
"winapi", "quote",
"syn",
] ]
[[package]] [[package]]
name = "bitflags" name = "argh_shared"
version = "1.2.1" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "64cb94155d965e3d37ffbbe7cc5b82c3dd79dd33bd48e536f73d2cfb8d85506f"
[[package]] [[package]]
name = "clap" name = "proc-macro2"
version = "2.33.3" version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
dependencies = [ dependencies = [
"ansi_term", "unicode-ident",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
] ]
[[package]] [[package]]
name = "hermit-abi" name = "quote"
version = "0.1.18" version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
dependencies = [ dependencies = [
"libc", "proc-macro2",
] ]
[[package]]
name = "libc"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
[[package]] [[package]]
name = "rust-nix-template" name = "rust-nix-template"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clap", "argh",
] ]
[[package]] [[package]]
name = "strsim" name = "syn"
version = "0.8.0" version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [ dependencies = [
"unicode-width", "proc-macro2",
"quote",
"unicode-ident",
] ]
[[package]] [[package]]
name = "unicode-width" name = "unicode-ident"
version = "0.1.8" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View file

@ -8,4 +8,4 @@ version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = "2.33.3" argh = "0.1.10"

View file

@ -1,21 +1,21 @@
use argh::FromArgs; use argh::FromArgs;
#[derive(FromArgs)] #[derive(FromArgs, Debug)]
/// Reach new heights. /// Reach new heights.
struct GoUp { struct Config {
/// whether or not to jump /// whether to be verbose
#[argh(switch, short = 'j')] #[argh(switch, short = 'v')]
jump: bool, verbose: bool,
/// how high to go /// an optional name to green
#[argh(option)] #[argh(option)]
height: usize, name: Option<String>,
/// an optional nickname for the pilot
#[argh(option)]
pilot_nickname: Option<String>,
} }
fn main() { fn main() {
let up: GoUp = argh::from_env(); let cfg: Config = argh::from_env();
if cfg.verbose {
println!("DEBUG {cfg:?}");
}
println!("Hello {}!", cfg.name.unwrap_or("world".to_string()));
} }