mkwin: implement argument forwarding and improved output formatting
This commit is contained in:
parent
48030490cb
commit
05dd7187ac
1 changed files with 29 additions and 8 deletions
|
@ -10,10 +10,23 @@ pub fn main() {
|
||||||
|
|
||||||
// build reference string
|
// build reference string
|
||||||
let mut arg_string = String::new();
|
let mut arg_string = String::new();
|
||||||
for arg in args.clone().finish() {
|
let mut arg_vec = args.clone().finish();
|
||||||
|
for arg in &arg_vec {
|
||||||
arg_string += &format!(" {}", arg.to_str().unwrap());
|
arg_string += &format!(" {}", arg.to_str().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// drain forwarded arguments
|
||||||
|
let forwarded: String;
|
||||||
|
if let Some(position) = arg_vec.iter().position(|a| a == "--") {
|
||||||
|
let mut build = String::new();
|
||||||
|
for arg in arg_vec.drain(position+1..) {
|
||||||
|
build = format!("{build} {}", arg.to_str().unwrap());
|
||||||
|
}
|
||||||
|
arg_vec.pop();
|
||||||
|
args = Arguments::from_vec(arg_vec);
|
||||||
|
forwarded = build;
|
||||||
|
} else { forwarded = String::new(); }
|
||||||
|
|
||||||
// consume breaking flags
|
// consume breaking flags
|
||||||
if args.contains(flag::HELP) {
|
if args.contains(flag::HELP) {
|
||||||
help_text();
|
help_text();
|
||||||
|
@ -55,16 +68,24 @@ pub fn main() {
|
||||||
error::missing_target();
|
error::missing_target();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// construct output
|
|
||||||
print!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n\n'{target}' ");
|
|
||||||
|
|
||||||
if path_convert {
|
// construct output
|
||||||
let flags = if let Some(i) = path_convert_flags { format!("-{i}") } else { String::new() };
|
print!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n\n'{target}'");
|
||||||
print!("`path-convert {flags} $@`");
|
|
||||||
} else {
|
// handle forwarded arguments
|
||||||
print!("$@");
|
if !forwarded.is_empty() {
|
||||||
|
print!("{forwarded}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle path convert flag
|
||||||
|
if path_convert {
|
||||||
|
let flags = if let Some(i) = path_convert_flags { format!(" -{i}") } else { String::new() };
|
||||||
|
print!(" `path-convert{flags} $@`");
|
||||||
|
} else {
|
||||||
|
print!(" $@");
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle quiet flag
|
||||||
if quiet {
|
if quiet {
|
||||||
print!(" > /dev/null 2>&1 &");
|
print!(" > /dev/null 2>&1 &");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue