Importantly, this currently does not include nested subcomands. A cleaner solution for those will have to be developed later.
NSWIJUHGFP34MVP46XYEKFEWQN6TEGDFSX3A7PIPVDOORTE5CB5QC
MT5RA7VYHKPZGI6YD2A2BABWL7ZDHJBFTODU6JEVZHTVAITVVLHAC
MIY7QPYK3EZTOGZF5PWU2ZKM7NG5ANWKNHS56FVTOY7PPATWLSSAC
C73UJ7ZYG4EE3YTK3N66GXPNWJHEBSRE4PDQBWMN6SKQ3U6ZYKXAC
BMG4FSHNV54VXDHNUVGZOMXQJWLFSUF3M5NCN7GJETNIF3QTHELQC
ZVDBFCW7ENFTFLAPTPHYWGXVSW2W7URZ2IJK67YAMDZVUYEXZIXAC
LEJN3E4QCBMUTQQKGKNHHAO6ER7R76SXEKBL46QAWZ63D3QRFLVQC
// Subcommand
#[command(subcommand)]
subcommand: Option<Subcmd>,
}
#[derive(Subcommand, Debug, Clone, Copy)]
pub enum Subcmd {
/// First subcommand
///
/// This explanation is also quite long.
/// It takes up multiple lines
One {
#[arg(long)]
times: u32,
},
/// Second subcommand
///
/// Another, even longer explanation.
/// Would it not be crazy
/// if this took up 3 lines??
Two {
#[arg(short = 'a', long)]
amount: i64,
},
fn source(state: &AppState, arg: &Arg) -> impl View<Arg> + ViewMarker {
el::span(if let Ok(arg_matches) = state.arg_matches.as_ref() {
fn source(arg_matches: Option<&ArgMatches>, arg: &Arg) -> impl View<Arg> + ViewMarker {
el::span(if let Some(arg_matches) = arg_matches.as_ref() {
pub fn args_view(state: &mut AppState) -> impl View<AppState> + ViewMarker {
el::div(
fn args_view(command: &Command, arg_matches: Option<&ArgMatches>) -> impl ViewSequence<AppState> {
command
.get_opts()
.map(|arg| {
Adapt::new(
|_state, _thunk| {
// TODO: actually re-compute this value
MessageResult::Nop
},
item(arg_matches, arg),
)
})
.collect::<Vec<_>>()
}
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),
.get_opts()
.map(|arg| {
Adapt::new(
|_state, _thunk| {
// TODO: actually re-compute this value
MessageResult::Nop
},
item(state, arg),
.get_subcommands()
.map(|subcommand| {
args_view(
subcommand,
arg_matches.and_then(|arg_matches| {
arg_matches.subcommand_matches(subcommand.get_name())
}),