Display arguments when input is invalid

finchie
Nov 20, 2023, 9:11 AM
ZVDBFCW7ENFTFLAPTPHYWGXVSW2W7URZ2IJK67YAMDZVUYEXZIXAC

Dependencies

  • [2] YTW5RB26 Refactor argument type handling into enum
  • [3] C73UJ7ZY Create simple `xilem_html` demo
  • [4] JFJVY57R List `clap` argument IDs
  • [5] BMG4FSHN Add basic `clap` support
  • [6] REI53XR4 Render argument state as HTML
  • [7] MIY7QPYK Refactor argument handling into a separate file
  • [8] G54GZBS4 Remove dependency on clap patches
  • [9] LEJN3E4Q Generate more semantic HTML

Change contents

  • edit in src/main.rs at line 35
    [3.514][3.514:575]()
    tracing::debug!("Matches: {:#?}", self.arg_matches);
  • edit in src/main.rs at line 44
    [3.405][3.1803:1972]()
    let default_matches = ArgMatches::default();
    let arg_matches = state.arg_matches.as_ref().unwrap_or(&default_matches);
    tracing::debug!("{:?}", arg_matches);
  • replacement in src/arg.rs at line 3
    [3.672][2.79:107]()
    use clap::{Arg, ValueHint};
    [3.672]
    [3.703]
    use clap::{Arg, ArgMatches, ValueHint};
  • edit in src/arg.rs at line 137
    [3.2974]
    [3.2974]
    } else if !arg.get_default_values().is_empty() {
    "Error parsing argument, potential defaults:"
  • replacement in src/arg.rs at line 140
    [3.2987][3.2987:3003]()
    "error"
    [3.2987]
    [3.3003]
    "Error parsing argument"
  • edit in src/arg.rs at line 161
    [3.3093]
    [3.3093]
    let default_matches = ArgMatches::default();
    let arg_matches = state.arg_matches.as_ref().unwrap_or(&default_matches);
  • replacement in src/arg.rs at line 165
    [3.3105][3.3105:3769]()
    state
    .arg_matches
    .as_ref()
    .iter()
    .map(|arg_matches| {
    arg_matches
    .get_raw_occurrences(&arg.get_id().as_str())
    .unwrap_or_default()
    .map(|os_strings| {
    el::li(
    os_strings
    .map(|s| s.to_string_lossy().to_string())
    .collect::<Vec<String>>()
    .join(" "),
    )
    })
    })
    .flatten()
    .collect::<Vec<el::Li<_>>>(),
    [3.3105]
    [3.3769]
    if let Ok(raw_occurences) = arg_matches.try_get_raw_occurrences(arg.get_id().as_str()) {
    raw_occurences
    .unwrap_or_default()
    .map(|os_strings| {
    el::li(
    os_strings
    .map(|s| s.to_string_lossy().to_string())
    .collect::<Vec<String>>()
    .join(" "),
    )
    })
    .collect::<Vec<el::Li<_>>>()
    } else {
    arg.get_default_values()
    .into_iter()
    .map(|os_str| os_str.to_string_lossy().to_string())
    .map(el::li)
    .collect::<Vec<el::Li<String>>>()
    },
  • replacement in src/arg.rs at line 208
    [3.4795][3.4795:4838]()
    el::div(if state.arg_matches.is_ok() {
    [3.4795]
    [3.4838]
    el::div(
  • replacement in src/arg.rs at line 221
    [3.5190][3.5190:5262]()
    .collect::<Vec<_>>()
    } else {
    Vec::new()
    })
    [3.5190]
    [3.5262]
    .collect::<Vec<_>>(),
    )