[ffx] fix panic on formatting error messages
Bug: b/401300250
Fixed: b/401300250
Change-Id: Iaaca9a432acea719e0e6fbdea02514579f8f828e
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1228424
Fuchsia-Auto-Submit: Colin Nelson <colnnelson@google.com>
Commit-Queue: Colin Nelson <colnnelson@google.com>
Reviewed-by: Steven Grady <slgrady@google.com>
diff --git a/src/developer/ffx/lib/fho/src/subtool.rs b/src/developer/ffx/lib/fho/src/subtool.rs
index 16c1cb2..4f73f96 100644
--- a/src/developer/ffx/lib/fho/src/subtool.rs
+++ b/src/developer/ffx/lib/fho/src/subtool.rs
@@ -33,8 +33,16 @@
/// Executes the tool. This is intended to be invoked by the user in main.
async fn execute_tool() {
let result = ffx_command::run::<FhoSuite<Self>>(ExecutableKind::Subtool).await;
- let cli = FfxCommandLine::from_env().unwrap();
- let should_format = cli.global.machine.is_some();
+ let should_format = match FfxCommandLine::from_env() {
+ Ok(cli) => cli.global.machine.is_some(),
+ Err(e) => {
+ tracing::warn!("Received error getting command line: {}", e);
+ match e {
+ Error::Help { .. } => false,
+ _ => true,
+ }
+ }
+ };
ffx_command::exit(result, should_format).await;
}
}