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

2
Cargo.lock generated
View file

@ -144,7 +144,7 @@ dependencies = [
[[package]]
name = "dolltool"
version = "1.0.0"
version = "1.1.0"
dependencies = [
"clap",
"num-bigint",

View file

@ -2,7 +2,7 @@
year = "2026"
license = "GPL-3.0-or-later"
name = "dolltool"
version = "1.0.0"
version = "1.1.0"
authors = ["ika4422"]
description = "A simple dollcode encoder, decoder, and generator inside your terminal :3"
edition = "2024"

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,25 +90,23 @@ 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) {
let num = input.parse::<BigUint>().unwrap();
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!");
process::exit(1);
}
}
}
} else if let Some(input) = args.decode {