File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,30 @@ def cls_to_gitlab_resource(cls: RESTObject) -> str:
106
106
return dasherized_lowercase .lower ()
107
107
108
108
109
+ class VerticalHelpFormatter (argparse .HelpFormatter ):
110
+ def format_help (self ) -> str :
111
+ result = super ().format_help ()
112
+ output = ""
113
+ for line in result .splitlines (keepends = True ):
114
+ if line .strip ().startswith ("{" ):
115
+ leading_whitespace = line .split ("{" )[0 ]
116
+ line = (
117
+ leading_whitespace
118
+ + f",\n { leading_whitespace } " .join (
119
+ line .strip ().strip ("{}" ).split ("," )
120
+ )
121
+ + "\n "
122
+ )
123
+ output += line
124
+ return output
125
+
126
+
109
127
def _get_base_parser (add_help : bool = True ) -> argparse .ArgumentParser :
110
128
parser = argparse .ArgumentParser (
111
129
add_help = add_help ,
112
130
description = "GitLab API Command Line Interface" ,
113
131
allow_abbrev = False ,
132
+ formatter_class = VerticalHelpFormatter ,
114
133
)
115
134
parser .add_argument ("--version" , help = "Display the version." , action = "store_true" )
116
135
parser .add_argument (
Original file line number Diff line number Diff line change @@ -377,7 +377,9 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
377
377
378
378
for cls in sorted (classes , key = operator .attrgetter ("__name__" )):
379
379
arg_name = cli .cls_to_gitlab_resource (cls )
380
- object_group = subparsers .add_parser (arg_name )
380
+ object_group = subparsers .add_parser (
381
+ arg_name , formatter_class = cli .VerticalHelpFormatter
382
+ )
381
383
382
384
object_subparsers = object_group .add_subparsers (
383
385
title = "action" ,
You can’t perform that action at this time.
0 commit comments