Create `command` module

finchie
Nov 25, 2023, 8:21 AM
SM7AIPUZE62XT62C56UYGTYOSTWLQYAIG7S2CJAHWWULSLVWXEHQC

Dependencies

  • [2] NSWIJUHG Add support for subcommands
  • [3] MIY7QPYK Refactor argument handling into a separate file
  • [4] REI53XR4 Render argument state as HTML
  • [5] A4E5KLI2 Turn arguments into sidebar
  • [6] BMG4FSHN Add basic `clap` support
  • [7] C73UJ7ZY Create simple `xilem_html` demo
  • [8] ZYNEMGAZ Use generated Typst code from Rust
  • [9] ZVDBFCW7 Display arguments when input is invalid
  • [10] MT5RA7VY Increase sidebar density
  • [11] G54GZBS4 Remove dependency on clap patches
  • [*] JFJVY57R List `clap` argument IDs

Change contents

  • edit in src/main.rs at line 3
    [3.13]
    [3.69]
    pub mod command;
    use command::command_view;
  • replacement in src/main.rs at line 9
    [3.141][3.64:133]()
    use xilem_html::{document_body, elements as el, App, View, ViewExt};
    [3.141]
    [3.0]
    use xilem_html::{document_body, elements as el, App, View, ViewExt, ViewMarker};
  • edit in src/main.rs at line 48
    [13.374]
    [3.632]
    fn sidebar(state: &AppState) -> impl View<AppState> + ViewMarker {
    let arg_matches = state.arg_matches.as_ref().ok();
    el::div((
    command_view(&state.command, arg_matches),
    state
    .command
    .get_subcommands()
    .map(|subcommand| {
    command_view(
    subcommand,
    arg_matches.and_then(|arg_matches| {
    arg_matches.subcommand_matches(subcommand.get_name())
    }),
    )
    })
    .collect::<Vec<_>>(),
    ))
    .attr("id", "sidebar")
    }
  • replacement in src/main.rs at line 77
    [3.921][2.0:30]()
    arg::sidebar(&state),
    [3.921]
    [3.1003]
    sidebar(&state),
  • replacement in src/arg.rs at line 210
    [3.4718][2.1118:1217]()
    fn args_view(command: &Command, arg_matches: Option<&ArgMatches>) -> impl ViewSequence<AppState> {
    [3.4718]
    [2.1217]
    pub fn args_view(
    command: &Command,
    arg_matches: Option<&ArgMatches>,
    ) -> impl ViewSequence<AppState> {
  • edit in src/arg.rs at line 227
    [2.1543][2.1543:1732](),[3.1077][3.4838:4873](),[2.1732][3.4838:4873](),[3.4838][3.4838:4873](),[3.4873][2.1733:2014](),[2.2014][3.5157:5190](),[3.5157][3.5157:5190](),[3.5190][3.1078:1112](),[3.1112][2.2015:2022](),[3.1118][3.5262:5291](),[2.2022][3.5262:5291](),[3.5262][3.5262:5291]()
    pub fn sidebar(state: &AppState) -> impl View<AppState> + ViewMarker {
    let arg_matches = state.arg_matches.as_ref().ok();
    el::div((
    args_view(&state.command, arg_matches),
    state
    .command
    .get_subcommands()
    .map(|subcommand| {
    args_view(
    subcommand,
    arg_matches.and_then(|arg_matches| {
    arg_matches.subcommand_matches(subcommand.get_name())
    }),
    )
    })
    .collect::<Vec<_>>(),
    ))
    .attr("id", "sidebar")
    }