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
|
||||
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());
|
||||
}
|
||||
|
||||
// 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
|
||||
if args.contains(flag::HELP) {
|
||||
help_text();
|
||||
|
@ -55,9 +68,16 @@ pub fn main() {
|
|||
error::missing_target();
|
||||
return;
|
||||
}
|
||||
|
||||
// construct output
|
||||
print!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n\n'{target}'");
|
||||
|
||||
// handle forwarded arguments
|
||||
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} $@`");
|
||||
|
@ -65,6 +85,7 @@ pub fn main() {
|
|||
print!(" $@");
|
||||
}
|
||||
|
||||
// handle quiet flag
|
||||
if quiet {
|
||||
print!(" > /dev/null 2>&1 &");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue