use crate::AppState;
use clap::{ArgMatches, Command};
use xilem_html::{elements as el, AnyView, View, ViewMarker, ViewSequence};
pub fn command_view(
command: &Command,
arg_matches: Option<&ArgMatches>,
) -> Box<dyn AnyView<AppState>> {
Box::new(el::section((
el::h2(command.get_name().to_string()),
crate::util::collapsible_docs(command.get_about(), command.get_long_about()),
crate::arg::args_view(command, arg_matches),
command
.get_subcommands()
.map(|subcmd| {
command_view(
subcmd,
arg_matches
.and_then(|arg_matches| arg_matches.subcommand_matches(subcmd.get_name())),
)
})
.collect::<Vec<_>>(),
)))
}