diff options
author | Albin Suresh <albin.suresh@softwareag.com> | 2022-04-04 20:29:15 +0530 |
---|---|---|
committer | Albin Suresh <albin.suresh@softwareag.com> | 2022-04-05 20:43:04 +0530 |
commit | d46b60b8f1e6dd91e93626588bc3a39bd72a4729 (patch) | |
tree | ee07059bcaf6588457b7daaf905af0ccb71f6a8f /plugins | |
parent | 45ea96aca1e148118d2f1726a5c7ec3669582b4c (diff) |
Improve parse error reporting of apt and apama plugins
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/tedge_apama_plugin/src/main.rs | 8 | ||||
-rw-r--r-- | plugins/tedge_apt_plugin/src/main.rs | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/plugins/tedge_apama_plugin/src/main.rs b/plugins/tedge_apama_plugin/src/main.rs index 9614e6f3..7ec18a8d 100644 --- a/plugins/tedge_apama_plugin/src/main.rs +++ b/plugins/tedge_apama_plugin/src/main.rs @@ -1,7 +1,7 @@ mod error; use crate::error::InternalError; -use clap::Parser; +use clap::{IntoApp, Parser}; use std::fs::{self, File}; use std::io::ErrorKind; use std::path::Path; @@ -302,7 +302,11 @@ fn main() { // On usage error, the process exits with a status code of 1 let apama = match ApamaCli::try_parse() { Ok(apamacli) => apamacli, - Err(_e) => { + Err(err) => { + eprintln!("ERROR: {}", err); + ApamaCli::command() + .print_help() + .expect("Failed to print command usage help message"); // re-write the clap exit_status from 2 to 1, if parse fails std::process::exit(1) } diff --git a/plugins/tedge_apt_plugin/src/main.rs b/plugins/tedge_apt_plugin/src/main.rs index cd74fe60..ed221d39 100644 --- a/plugins/tedge_apt_plugin/src/main.rs +++ b/plugins/tedge_apt_plugin/src/main.rs @@ -3,7 +3,7 @@ mod module_check; use crate::error::InternalError; use crate::module_check::PackageMetadata; -use clap::Parser; +use clap::{IntoApp, Parser}; use serde::Deserialize; use std::io::{self}; use std::process::{Command, ExitStatus, Stdio}; @@ -238,7 +238,11 @@ fn main() { let apt = match AptCli::try_parse() { Ok(aptcli) => aptcli, - Err(_e) => { + Err(err) => { + eprintln!("ERROR: {}", err); + AptCli::command() + .print_help() + .expect("Failed to print usage help"); // re-write the clap exit_status from 2 to 1, if parse fails std::process::exit(1) } |