mkwin: added empty flag to not pass $@

This commit is contained in:
Valerie Wolfe 2024-06-11 11:29:57 -04:00
parent 5386fbdf63
commit a3b3dce376
2 changed files with 14 additions and 7 deletions

View file

@ -1,6 +1,7 @@
//! constants for flag arguments //! constants for flag arguments
pub const HELP: [&str;2] = ["-h", "--help"]; pub const HELP: [&str;2] = ["-h", "--help"];
pub const EMPTY: &str = "--empty";
pub const PATH_CONVERT: &str = "--pc"; pub const PATH_CONVERT: &str = "--pc";
pub const QUIET: [&str;2] = ["-q", "--quiet"]; pub const QUIET: [&str;2] = ["-q", "--quiet"];

View file

@ -52,6 +52,7 @@ pub fn main() {
} }
// consume simple flags // consume simple flags
let empty = args.contains(flag::EMPTY);
let quiet = args.contains(flag::QUIET); let quiet = args.contains(flag::QUIET);
// get target executable // get target executable
@ -77,12 +78,15 @@ pub fn main() {
print!("{forwarded}"); print!("{forwarded}");
} }
// handle path convert flag // handle empty flag
if path_convert { if !empty {
let flags = if let Some(i) = path_convert_flags { format!(" -{i}") } else { String::new() }; // handle path convert flag
print!(" `path-convert{flags} $@`"); if path_convert {
} else { let flags = if let Some(i) = path_convert_flags { format!(" -{i}") } else { String::new() };
print!(" $@"); print!(" `path-convert{flags} $@`");
} else {
print!(" $@");
}
} }
// handle quiet flag // handle quiet flag
@ -106,9 +110,11 @@ args:
flags: flags:
-h, --help Shows this help text and exit. -h, --help Shows this help text and exit.
--empty The resulting script will not pass arguments.
--pc=<flags> The resulting script will use the 'path-convert' to convert --pc=<flags> The resulting script will use the 'path-convert' to convert
arguments from UNIX to DOS, with the provided set of flags arguments from UNIX to DOS, with the provided set of flags
('x' for no flags). ('x' for no flags).
-q, --quiet The resulting script will run the target program in the -q, --quiet The resulting script will run the target program in the
background and with its outputs redirected to '/dev/null'.", background and with its outputs redirected to '/dev/null'.",