A simple shell wrapper that handles argument parsing
0
fork

Configure Feed

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

make required args actually required

I might've forgotten to add the check that all required arguments were
passed

Fly ab27d891 b94b83d1

+13 -1
+13 -1
src/main.rs
··· 147 147 let mut optional_args: Vec<(String, String)> = Vec::new(); 148 148 let mut flags: Vec<String> = Vec::new(); 149 149 150 + let mut found_required_args: Vec<String> = Vec::new(); 151 + 150 152 for (arg, value) in args { 151 153 match arg { 152 - config::Arg::Required(_, pos) => { 154 + config::Arg::Required(arg, pos) => { 155 + found_required_args.push(arg.to_owned()); 153 156 required_args.insert(pos - 1, value); 154 157 } 155 158 config::Arg::Optional(arg) => { ··· 161 164 config::Arg::Flag(arg) => { 162 165 flags.push(format!("ARGSH_{}", arg.replace('-', "_").to_uppercase())); 163 166 } 167 + } 168 + } 169 + 170 + for arg in config.args.into_iter().filter_map(|arg| match arg { 171 + config::Arg::Required(arg, _) => Some(arg), 172 + _ => None, 173 + }) { 174 + if !found_required_args.contains(&arg) { 175 + return Err(format!("Required argument '--{arg}' is missing").into()); 164 176 } 165 177 } 166 178