A simple shell wrapper that handles argument parsing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

turns out env doesn't like $, changed to #

fly.nonsense.now b94b83d1 d14980f0

verified
+3 -3
+1 -1
README.md
··· 20 20 21 21 A plain argument such as `arg` is a required argument, which will be passed to the script as a positional argument. 22 22 23 - An argument starting with `$` such as `$arg` is an optional argument, which will be passed to the script as an environment variable like `$ARGSH_ARG`, where all `-` get converted to `_`. 23 + An argument starting with `#` such as `#arg` is an optional argument, which will be passed to the script as an environment variable like `$ARGSH_ARG`, where all `-` get converted to `_`. 24 24 25 25 An argument starting with `?` such as `?arg` is a flag, which will be passed to the script as an environment variable like `$ARGSH_ARG`, where all `-` get converted to `_`, with the value set to `1`, the value is irrelevant, just check if the variable is empty. 26 26
+1 -1
src/main.rs
··· 57 57 let mut pos: u8 = 0; 58 58 59 59 for arg in args_raw.split(';') { 60 - if let Some(arg) = arg.strip_prefix('$') { 60 + if let Some(arg) = arg.strip_prefix('#') { 61 61 if is_valid_name(arg) { 62 62 args.push(Arg::Optional(arg.to_owned())); 63 63 } else {
+1 -1
test
··· 1 - #!./target/debug/argsh bash|required;also-required;?flag;$optional;$second-optional 1 + #!./target/debug/argsh bash|required;also-required;?flag;#optional;#second-optional 2 2 3 3 echo "--required on pos 1: $1" 4 4 echo "--also-required on pos 2: $2"