@@ -400,10 +400,18 @@ def _format_actions_usage(self, actions, groups):
400400 except ValueError :
401401 continue
402402 else :
403- end = start + len (group ._group_actions )
403+ group_action_count = len (group ._group_actions )
404+ end = start + group_action_count
404405 if actions [start :end ] == group ._group_actions :
406+
407+ suppressed_actions_count = 0
405408 for action in group ._group_actions :
406409 group_actions .add (action )
410+ if action .help is SUPPRESS :
411+ suppressed_actions_count += 1
412+
413+ exposed_actions_count = group_action_count - suppressed_actions_count
414+
407415 if not group .required :
408416 if start in inserts :
409417 inserts [start ] += ' ['
@@ -413,7 +421,7 @@ def _format_actions_usage(self, actions, groups):
413421 inserts [end ] += ']'
414422 else :
415423 inserts [end ] = ']'
416- else :
424+ elif exposed_actions_count > 1 :
417425 if start in inserts :
418426 inserts [start ] += ' ('
419427 else :
@@ -487,7 +495,6 @@ def _format_actions_usage(self, actions, groups):
487495 text = _re .sub (r'(%s) ' % open , r'\1' , text )
488496 text = _re .sub (r' (%s)' % close , r'\1' , text )
489497 text = _re .sub (r'%s *%s' % (open , close ), r'' , text )
490- text = _re .sub (r'\(([^|]*)\)' , r'\1' , text )
491498 text = text .strip ()
492499
493500 # return the text
0 commit comments