diff --git a/installer-gui/src-tauri/src/introspect.rs b/installer-gui/src-tauri/src/introspect.rs index 4dad394..d43713f 100644 --- a/installer-gui/src-tauri/src/introspect.rs +++ b/installer-gui/src-tauri/src/introspect.rs @@ -2,6 +2,7 @@ //! serializable by serde. use std::collections::HashMap; +use anyhow::Context; use serde::Serialize; use crate::modifiers; @@ -50,16 +51,22 @@ struct Subcommand<'a> { } impl Argument<'_> { - fn new<'a>( + fn try_new<'a>( argument: &'a clap::Arg, modifier: &modifiers::ArgumentModifier<'static>, - ) -> Option> { + ) -> anyhow::Result> { // if an argument doesn't have the data we need, it's silently dropped from the GUI, however, // tests should prevent this from happening and we could add logging messages about this in // the future if desired - Some(Argument { + let partial_flag = argument.get_long().with_context(|| { + format!( + "Missing long form command line flag for {}", + argument.get_id().as_str(), + ) + })?; + Ok(Argument { advanced: modifier.advanced, - flag: format!("--{}", argument.get_long()?), + flag: format!("--{}", partial_flag), label: modifier.gui_label, takes_values: argument.get_action().takes_values(), }) @@ -86,7 +93,7 @@ impl Subcommand<'_> { .filter_map(|arg_modifier| { argument_map .get(arg_modifier.clap_id) - .and_then(|arg| Argument::new(arg, arg_modifier)) + .and_then(|arg| Argument::try_new(arg, arg_modifier).ok()) }) .collect(), command: modifier.command,