@@ -74,6 +74,35 @@ def invoke(self, ctx: click.Context):
74
74
# If we have a generic exception, we wrap it in a ClickException
75
75
raise CLIError (str (e )) from e
76
76
77
+ def format_help (self , ctx : click .Context , formatter : click .HelpFormatter ) -> None :
78
+ """Custom help formatter that makes all section headers bold and uppercase."""
79
+ from localstack .constants import VERSION # Import at the top of the file if not already there
80
+
81
+ formatter .write_text (f"LocalStack CLI v{ VERSION } " ) # Add version at the top
82
+ self .format_help_text (ctx , formatter )
83
+ formatter .write_text ("" ) # Add blank line after help text
84
+ self .format_usage (ctx , formatter )
85
+ self .format_options (ctx , formatter )
86
+ self .format_commands (ctx , formatter )
87
+
88
+ def format_usage (self , ctx : click .Context , formatter : click .HelpFormatter ) -> None :
89
+ """Override usage formatting to make the header bold and uppercase."""
90
+ formatter .write_text ("\033 [1mUSAGE\033 [0m" ) # Write the header separately
91
+ formatter .write_text ("localstack [OPTIONS] COMMAND [ARGS]..." )
92
+
93
+ def format_options (self , ctx : click .Context , formatter : click .HelpFormatter ) -> None :
94
+ """Override options formatting to make the header bold and uppercase."""
95
+ opts = []
96
+ for param in ctx .command .get_params (ctx ):
97
+ rv = param .get_help_record (ctx )
98
+ if rv is not None :
99
+ opts .append (rv )
100
+
101
+ if opts :
102
+ formatter .write_text ("" )
103
+ formatter .write_text ("\033 [1mOPTIONS\033 [0m" )
104
+ formatter .write_dl (opts )
105
+
77
106
def format_commands (self , ctx : click .Context , formatter : click .HelpFormatter ) -> None :
78
107
"""Extra format methods for multi methods that adds all the commands after the options. It also
79
108
groups commands into command categories."""
@@ -100,8 +129,9 @@ def format_commands(self, ctx: click.Context, formatter: click.HelpFormatter) ->
100
129
101
130
for category , rows in categories .items ():
102
131
if rows :
103
- with formatter .section (category ):
104
- formatter .write_dl (rows )
132
+ formatter .write_text ("" )
133
+ formatter .write_text (f"\033 [1m{ category .upper ()} \033 [0m" )
134
+ formatter .write_dl (rows )
105
135
106
136
def _get_category (self , cmd ) -> str :
107
137
if cmd .deprecated :
@@ -112,7 +142,6 @@ def _get_category(self, cmd) -> str:
112
142
113
143
return "Commands"
114
144
115
-
116
145
def create_with_plugins () -> LocalstackCli :
117
146
"""
118
147
Creates a LocalstackCli instance with all cli plugins loaded.
0 commit comments