Skip to content

Commit

Permalink
to derive
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamontov committed Dec 4, 2024
1 parent 3a4308e commit 8014159
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- uses: actions/checkout@v4
- run: rustup update
- run: rustc -V
- run: rustup -V
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
57 changes: 27 additions & 30 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
use clap::{arg, Parser};
use clap_derive::Parser;
use passgenlib::Passgen;
use clap::{arg, command, value_parser, Arg, ColorChoice, Parser};

/*#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
#[derive(Parser, Debug)]
#[command(version, about)]
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,
}*/
/// Length of result.
#[arg(default_value_t = 8)]
length: u32,
/// User defined character set.
/// ⚠️ This set of characters will exclude all other rules.
#[arg(short, long, default_value = "")]
custom_charset: String,
}

fn main() {



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));


let args = Args::parse();

if args.custom_charset != "" {
println!(
"{}",
Passgen::default_strong_and_usab().generate(args.length)
);
} else {
println!(
"{}",
Passgen::new()
.set_custom_charset(args.custom_charset.leak())
.generate(args.length)
);
}
}

0 comments on commit 8014159

Please sign in to comment.