Skip to content

Commit

Permalink
clap
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamontov committed Nov 30, 2024
1 parent d450d20 commit 3a4308e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ categories = ["authentication", "cryptography", "command-line-utilities"]
exclude = [".*"]

[dependencies]
passgen-lib = { git = 'https://github.com/mammothcoding/passgen-lib' }
passgen-lib = "*"
clap = { version = "4.5.21", features = ["cargo"] }
clap_derive = "*"
33 changes: 32 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
use passgenlib::Passgen;
use clap::{arg, command, value_parser, Arg, ColorChoice, Parser};

/*#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[arg(short, long)]
name: String,
/// Number of times to greet
#[arg(short, long, default_value_t = 1)]
count: u8,
}*/

fn main() {
println!("{}", Passgen::default_strong_and_usab().generate(8))



let matches = command!()
.arg(
arg!([length])
.value_parser(value_parser!(u32))
.default_value("8"),
)
.color(ColorChoice::Always)
.get_matches();

let length: &u32 = matches
.get_one::<u32>("length")
.expect("length must be provided");

println!("{}", Passgen::default().generate(*length));


}

0 comments on commit 3a4308e

Please sign in to comment.