(
&self,
cmd: &clap::Command,
arg: Option<&clap::Arg>,
value: &std::ffi::OsStr,
)
| 179 | type Value = CommaSeparated<T>; |
| 180 | |
| 181 | fn parse_ref( |
| 182 | &self, |
| 183 | cmd: &clap::Command, |
| 184 | arg: Option<&clap::Arg>, |
| 185 | value: &std::ffi::OsStr, |
| 186 | ) -> Result<Self::Value, Error> { |
| 187 | let val = StringValueParser::new().parse_ref(cmd, arg, value)?; |
| 188 | |
| 189 | let options = T::OPTIONS; |
| 190 | let arg = arg.expect("should always have an argument"); |
| 191 | let arg_long = arg.get_long().expect("should have a long name specified"); |
| 192 | let arg_short = arg.get_short().expect("should have a short name specified"); |
| 193 | |
| 194 | // Handle `-O help` which dumps all the `-O` options, their messages, |
| 195 | // and then exits. |
| 196 | if val == "help" { |
| 197 | let mut max = 0; |
| 198 | for d in options { |
| 199 | max = max.max(d.name.display_string().len() + d.val_help.len()); |
| 200 | } |
| 201 | println!("Available {arg_long} options:\n"); |
| 202 | for d in options { |
| 203 | print!( |
| 204 | " -{arg_short} {:>1$}", |
| 205 | d.name.display_string(), |
| 206 | max - d.val_help.len() |
| 207 | ); |
| 208 | print!("{}", d.val_help); |
| 209 | print!(" --"); |
| 210 | if val == "help" { |
| 211 | for line in d.docs.lines().map(|s| s.trim()) { |
| 212 | if line.is_empty() { |
| 213 | break; |
| 214 | } |
| 215 | print!(" {line}"); |
| 216 | } |
| 217 | println!(); |
| 218 | } else { |
| 219 | println!(); |
| 220 | for line in d.docs.lines().map(|s| s.trim()) { |
| 221 | let line = line.trim(); |
| 222 | println!(" {line}"); |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | println!("\npass `-{arg_short} help-long` to see longer-form explanations"); |
| 227 | std::process::exit(0); |
| 228 | } |
| 229 | if val == "help-long" { |
| 230 | println!("Available {arg_long} options:\n"); |
| 231 | for d in options { |
| 232 | println!( |
| 233 | " -{arg_short} {}{} --", |
| 234 | d.name.display_string(), |
| 235 | d.val_help |
| 236 | ); |
| 237 | println!(); |
| 238 | for line in d.docs.lines().map(|s| s.trim()) { |
nothing calls this directly
no test coverage detected