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:
parent
a9e48d63d1
commit
117cead713
3 changed files with 18 additions and 14 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -144,7 +144,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dolltool"
|
name = "dolltool"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
year = "2026"
|
year = "2026"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
name = "dolltool"
|
name = "dolltool"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
authors = ["ika4422"]
|
authors = ["ika4422"]
|
||||||
description = "A simple dollcode encoder, decoder, and generator inside your terminal :3"
|
description = "A simple dollcode encoder, decoder, and generator inside your terminal :3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
|
||||||
22
src/main.rs
22
src/main.rs
|
|
@ -67,7 +67,13 @@ fn main() {
|
||||||
if args.no_doll {
|
if args.no_doll {
|
||||||
println!("{}", generated);
|
println!("{}", generated);
|
||||||
} else {
|
} 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) => {
|
Some(num) => {
|
||||||
println!("{} :: {}", generated, to_dollcode(num).unwrap());
|
println!("{} :: {}", generated, to_dollcode(num).unwrap());
|
||||||
}
|
}
|
||||||
|
|
@ -84,25 +90,23 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(input) = args.encode {
|
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
|
let result: Vec<String> = input
|
||||||
.chars()
|
.chars()
|
||||||
.map(|c| to_dollcode(BigUint::from(c as u64)).unwrap())
|
.map(|c| to_dollcode(BigUint::from(c as u64)).unwrap())
|
||||||
.collect();
|
.collect();
|
||||||
println!("{}", result.join(" "));
|
println!("{}", result.join(" "));
|
||||||
} else {
|
} else {
|
||||||
match input.parse::<BigUint>() {
|
let num = input.parse::<BigUint>().unwrap();
|
||||||
Ok(num) => match to_dollcode(num) {
|
|
||||||
|
match to_dollcode(num) {
|
||||||
Ok(code) => println!("{}", code),
|
Ok(code) => println!("{}", code),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error: {}", e);
|
eprintln!("Error: {}", e);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(_) => {
|
|
||||||
eprintln!("Error: input must be a positive integer!");
|
|
||||||
process::exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(input) = args.decode {
|
} else if let Some(input) = args.decode {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue