diff --git a/src/commands.rs b/src/commands.rs index 9ecfec3..7397db8 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -69,7 +69,7 @@ pub fn run_encode(input: &str, base: u32, text: bool) { } } -pub fn run_decode(input: &str, base: u32, text: bool) { +pub fn run_decode(input: &str, base: u32, text: bool, all_bases: bool) { let decode_as_text = text || input.split_whitespace().count() > 1; if decode_as_text { @@ -93,7 +93,16 @@ pub fn run_decode(input: &str, base: u32, text: bool) { println!("{}", decoded_chars); } else { match from_dollcode(input) { - Ok(val) => println!("{}", val.to_str_radix(base)), + Ok(val) => { + if all_bases { + println!("bin :: {}", val.to_str_radix(2)); + println!("oct :: {}", val.to_str_radix(8)); + println!("dec :: {}", val.to_str_radix(10)); + println!("hex :: {}", val.to_str_radix(16)); + } else { + println!("{}", val.to_str_radix(base)); + } + } Err(e) => { eprintln!("Error: {}", e); process::exit(1); diff --git a/src/main.rs b/src/main.rs index cb2a4e4..862230d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,6 +50,6 @@ fn main() { } else if let Some(input) = args.encode { commands::run_encode(&input, args.base.radix(), args.text); } else if let Some(input) = args.decode { - commands::run_decode(&input, args.base.radix(), args.text); + commands::run_decode(&input, args.base.radix(), args.text, args.all_bases); } } diff --git a/src/models.rs b/src/models.rs index 43cfe07..5424653 100644 --- a/src/models.rs +++ b/src/models.rs @@ -23,6 +23,10 @@ pub struct Args { /// Input/output base for integers (2-36, or bin/oct/dec/hex/..) pub base: Base, + #[arg(long, default_value_t = false)] + /// Output result in binary, octal, decimal and hex + pub all_bases: bool, + #[arg(long, default_value_t = false)] /// Will generate codes without encoding it into dollcode pub no_doll: bool,