Lot of small changes, mostly introduces the ArgState
struct and converts clap MatchedArgs
to Vec<ArgState>
. Unfortunately this solution requires a patched version of clap so will need to figure something else out in the long-term.
REI53XR4WDH5EKLTXTFVTOVWCCFRWTFH4GQS6DSNM5LSRFTX7HJQC
matches: Option<Result<ArgMatches, clap::Error>>,
arg_ids: Vec<String>,
args: Vec<ArgState>,
}
struct ArgState {
name: String,
source: ValueSource,
raw_values: Vec<String>,
// Keep the value as a string, but store its corresponding type info
type_id: AnyValueId,
self.matches = Some(matches);
ArgState {
name: key.to_string(),
source: value.source().unwrap_or(ValueSource::DefaultValue),
raw_values: value
.raw_vals()
.flatten()
.map(|raw_value| raw_value.to_string_lossy().to_string())
.collect(),
type_id: value
.type_id()
.unwrap_or(AnyValueId::of::<dyn std::any::Any>()),
fn arg_item(id: &String) -> impl View<AppState> + ViewMarker {
el::li(id.to_owned())
fn arg_item(arg: &ArgState) -> impl View<AppState> + ViewMarker {
let source = match arg.source {
ValueSource::DefaultValue => "default",
ValueSource::EnvVariable => "environment",
ValueSource::CommandLine => "cmdline",
_ => "todo",
};
el::div((
el::h2(arg.name.clone()),
el::div((
format!("{:?}", arg.type_id),
el::div("test").attr("class", "hover_content"),
))
.attr("class", "hoverable"),
el::div(source),
el::ul(
arg.raw_values
.iter()
.map(|arg| el::li(arg.clone()))
.collect::<Vec<_>>(),
),
))
name = "tracing"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
dependencies = [
"once_cell",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
dependencies = [
"sharded-slab",
"thread_local",
"tracing-core",
]
[[package]]
name = "tracing-wasm"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07"
dependencies = [
"tracing",
"tracing-subscriber",
"wasm-bindgen",
]
[[package]]