@@ -106,11 +106,49 @@ 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_action (self , action : Any ) -> str :
111
+ result = super ()._format_action (action = action )
112
+ if not result .strip ().startswith ("{" ):
113
+ return result
114
+ output = ""
115
+ for line in result .splitlines (keepends = True ):
116
+ if line .strip ().startswith ("{" ):
117
+ line = line .strip ().strip (" {}" )
118
+ values = line .split ("," )
119
+ indentation = self ._indent_increment * " "
120
+ output += indentation + "{\n "
121
+ sep = ",\n " + (indentation * 2 )
122
+ output += (indentation * 2 ) + sep .join (values )
123
+ output += "\n " + indentation + "}\n "
124
+ else :
125
+ output += line
126
+ return output
127
+
128
+ def _format_usage (self , usage : Any , actions : Any , groups : Any , prefix : Any ) -> str :
129
+ result = super ()._format_usage (
130
+ usage = usage , actions = actions , groups = groups , prefix = prefix
131
+ )
132
+ new_result = ""
133
+ for line in result .splitlines (keepends = True ):
134
+ if not line .lstrip ().startswith ("{" ):
135
+ new_result += line
136
+ continue
137
+ leading_whitespace = line .split ("{" )[0 ]
138
+ line = line .strip ().strip (" {}" )
139
+ new_result += leading_whitespace + "{\n "
140
+ for resource in line .split ("," ):
141
+ new_result += f"{ leading_whitespace } { resource } ,\n "
142
+ new_result += leading_whitespace + "}\n "
143
+ return new_result
144
+
145
+
109
146
def _get_base_parser (add_help : bool = True ) -> argparse .ArgumentParser :
110
147
parser = argparse .ArgumentParser (
111
148
add_help = add_help ,
112
149
description = "GitLab API Command Line Interface" ,
113
150
allow_abbrev = False ,
151
+ formatter_class = VerticalHelpFormatter ,
114
152
)
115
153
parser .add_argument ("--version" , help = "Display the version." , action = "store_true" )
116
154
parser .add_argument (
0 commit comments