v1.1.0 :: added autodetection for strings instead of requiring text flag for encoding and added encode as string override with text flag to pattern generation

This commit is contained in:
ika4422 2026-02-10 21:09:16 +00:00
parent a9e48d63d1
commit 117cead713
No known key found for this signature in database
3 changed files with 18 additions and 14 deletions

View file

@ -67,7 +67,13 @@ fn main() {
if args.no_doll {
println!("{}", generated);
} else {
match BigUint::parse_bytes(generated.as_bytes(), 10) {
let as_num = if args.text {
None
} else {
BigUint::parse_bytes(generated.as_bytes(), 10)
};
match as_num {
Some(num) => {
println!("{} :: {}", generated, to_dollcode(num).unwrap());
}
@ -84,23 +90,21 @@ fn main() {
}
if let Some(input) = args.encode {
if args.text {
let encode_as_text = args.text || input.parse::<BigUint>().is_err();
if encode_as_text {
let result: Vec<String> = input
.chars()
.map(|c| to_dollcode(BigUint::from(c as u64)).unwrap())
.collect();
println!("{}", result.join(" "));
} else {
match input.parse::<BigUint>() {
Ok(num) => match to_dollcode(num) {
Ok(code) => println!("{}", code),
Err(e) => {
eprintln!("Error: {}", e);
process::exit(1);
}
},
Err(_) => {
eprintln!("Error: input must be a positive integer!");
let num = input.parse::<BigUint>().unwrap();
match to_dollcode(num) {
Ok(code) => println!("{}", code),
Err(e) => {
eprintln!("Error: {}", e);
process::exit(1);
}
}