@@ -446,6 +446,7 @@ impl<F: ErrorFormatter> Error<F> {
446446 subcmd : String ,
447447 did_you_mean : Vec < String > ,
448448 name : String ,
449+ suggested_trailing_arg : bool ,
449450 usage : Option < StyledStr > ,
450451 ) -> Self {
451452 use std:: fmt:: Write as _;
@@ -456,15 +457,19 @@ impl<F: ErrorFormatter> Error<F> {
456457
457458 #[ cfg( feature = "error-context" ) ]
458459 {
459- let mut styled_suggestion = StyledStr :: new ( ) ;
460- let _ = write ! (
461- styled_suggestion,
462- "to pass '{}{subcmd}{}' as a value, use '{}{name} -- {subcmd}{}'" ,
463- invalid. render( ) ,
464- invalid. render_reset( ) ,
465- valid. render( ) ,
466- valid. render_reset( )
467- ) ;
460+ let mut suggestions = vec ! [ ] ;
461+ if suggested_trailing_arg {
462+ let mut styled_suggestion = StyledStr :: new ( ) ;
463+ let _ = write ! (
464+ styled_suggestion,
465+ "to pass '{}{subcmd}{}' as a value, use '{}{name} -- {subcmd}{}'" ,
466+ invalid. render( ) ,
467+ invalid. render_reset( ) ,
468+ valid. render( ) ,
469+ valid. render_reset( )
470+ ) ;
471+ suggestions. push ( styled_suggestion) ;
472+ }
468473
469474 err = err. extend_context_unchecked ( [
470475 ( ContextKind :: InvalidSubcommand , ContextValue :: String ( subcmd) ) ,
@@ -474,7 +479,7 @@ impl<F: ErrorFormatter> Error<F> {
474479 ) ,
475480 (
476481 ContextKind :: Suggested ,
477- ContextValue :: StyledStrs ( vec ! [ styled_suggestion ] ) ,
482+ ContextValue :: StyledStrs ( suggestions ) ,
478483 ) ,
479484 ] ) ;
480485 if let Some ( usage) = usage {
0 commit comments