File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,25 @@ pub fn run() {
7575// sets up warning and progress reporting and calls run_app and does error handling for its result
7676// returns Ok if we should exit with code 0, Err if we should exit with 1
7777fn run_inner ( ) -> Result < ( ) , ( ) > {
78- let matches = Opt :: parse ( ) ;
78+ let matches = match Opt :: try_parse ( ) . context ( "Failed to parse arguments" ) {
79+ Ok ( matches) => matches,
80+ Err ( e) => {
81+ // CLI was called incorrectly
82+ let causes: Vec < String > = e. chain ( ) . map ( |e| format ! ( "Caused by: {}" , e) ) . collect ( ) ;
83+ let error_output = OutputKind :: OutputData ( Box :: new ( OutputData {
84+ status : Status :: Finished ,
85+ message : e. to_string ( ) ,
86+ result : OutputResult :: Error ,
87+ data : Some ( DataKind :: Error {
88+ kind : Kind :: Generic ,
89+ trace : causes,
90+ } ) ,
91+ } ) ) ;
92+ print_output ( & error_output, false )
93+ . expect ( "failed to print output" ) ;
94+ return Err ( ( ) ) ;
95+ }
96+ } ;
7997 let pretty = matches. pretty ;
8098
8199 notification_reporter:: init ( Box :: new ( move |warning| {
You can’t perform that action at this time.
0 commit comments