added quote flag
This commit is contained in:
parent
4c84321ff4
commit
c84e23f95b
2 changed files with 11 additions and 2 deletions
|
@ -4,7 +4,7 @@ version = "0.0.2"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
pico-args = "0.5.0"
|
||||
pico-args = { version = "0.5.0", features = [ "combined-flags" ] }
|
||||
|
||||
[profile.release]
|
||||
opt-level = 's'
|
||||
|
|
|
@ -4,9 +4,18 @@ use pico_args::Arguments;
|
|||
|
||||
const DRIVE: &str = "/mnt/c/";
|
||||
|
||||
const QUOTED: [&str;2] = [ "-q", "--quotes" ];
|
||||
|
||||
pub fn main() {
|
||||
let mut args = Arguments::from_env();
|
||||
|
||||
// handle quote flag
|
||||
let quotes: &str =
|
||||
if args.contains(QUOTED) {
|
||||
if args.contains(QUOTED) { "\"" } // -qq -> "..." (output with double quotes)
|
||||
else { "'" } // -q -> '...' (output with single quotes)
|
||||
} else { "" }; // _ -> ... (output with no quotes)
|
||||
|
||||
loop {
|
||||
let next = args.subcommand().unwrap();
|
||||
if let Some(arg) = next {
|
||||
|
@ -28,7 +37,7 @@ pub fn main() {
|
|||
output = output.replace("/", "\\");
|
||||
|
||||
// emit to stdout
|
||||
println!("{output}");
|
||||
println!("{quotes}{output}{quotes}");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue