4646
4747# if any of these arguments are given, we don't need to prompt for configuration
4848skip_config = (
49- any (
50- c in argv
51- for c in ["--skip-config" , "--version" , "completion" ]
52- )
49+ any (c in argv for c in ["--skip-config" , "--version" , "completion" ])
5350 or TEST_MODE
5451)
5552
@@ -110,24 +107,34 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
110107 # if not spec was found and we weren't baking, we're doomed
111108 sys .exit (ExitCodes .ARGUMENT_ERROR )
112109
113- if parsed .command == "set-custom-alias" or parsed . command == "remove-custom-alias" :
110+ if parsed .command in ( "set-custom-alias" , "remove-custom-alias" ) :
114111 # Ensure both --command and --alias are provided
115112 # TODO: Can we use argparse for these
116113 if len (args ) == 4 :
117114 if args [0 ] != "--command" or args [2 ] != "--alias" :
118- print ("Usage: linode-cli set-custom-alias --command [COMMAND] --alias [ALIAS]" , file = sys .stderr )
115+ print (
116+ "Usage: linode-cli set-custom-alias --command "
117+ "[COMMAND] --alias [ALIAS]" ,
118+ file = sys .stderr ,
119+ )
119120 sys .exit (ExitCodes .ARGUMENT_ERROR )
120121
121122 # Get the indexes for --command and --alias
122123 try :
123124 command_index = args .index ("--command" ) + 1
124125 alias_index = args .index ("--alias" ) + 1
125126 except ValueError :
126- print ("Both --command and --alias arguments are required." , file = sys .stderr )
127+ print (
128+ "Both --command and --alias arguments are required." ,
129+ file = sys .stderr ,
130+ )
127131 sys .exit (ExitCodes .ARGUMENT_ERROR )
128132
129133 if command_index >= len (args ) or alias_index >= len (args ):
130- print ("Both --command and --alias arguments must have valid values." , file = sys .stderr )
134+ print (
135+ "Both --command and --alias arguments must have valid values." ,
136+ file = sys .stderr ,
137+ )
131138 sys .exit (ExitCodes .ARGUMENT_ERROR )
132139
133140 # Retrieve the command and alias from arguments
@@ -136,7 +143,9 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
136143
137144 # Check if the command is valid
138145 if command not in cli .ops :
139- print (f"Error: '{ command } ' is not a valid command." , file = sys .stderr )
146+ print (
147+ f"Error: '{ command } ' is not a valid command." , file = sys .stderr
148+ )
140149 sys .exit (ExitCodes .ARGUMENT_ERROR )
141150
142151 # Set the alias if it does not already exist
@@ -145,15 +154,19 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
145154 cli .config .set_custom_alias (alias , command )
146155 print (f"Custom alias '{ alias } ' set for command '{ command } '" )
147156 else :
148- print (f"Custom alias '{ alias } ' already set for command '{ command } '" )
157+ print (
158+ f"Custom alias '{ alias } ' already set for command '{ command } '"
159+ )
149160
150161 # Remove the alias if it already exists
151162 if parsed .command == "remove-custom-alias" :
152163 if (alias , command ) in cli .config .get_custom_aliases ().items ():
153164 cli .config .remove_custom_alias (alias , command )
154165 print (f"Custom alias '{ alias } ' removed for command '{ command } '" )
155166 else :
156- print (f"Custom alias '{ alias } ' does not exist for command '{ command } '" )
167+ print (
168+ f"Custom alias '{ alias } ' does not exist for command '{ command } '"
169+ )
157170
158171 sys .exit (ExitCodes .SUCCESS )
159172
@@ -271,20 +284,23 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
271284 sys .exit (ExitCodes .UNRECOGNIZED_COMMAND )
272285
273286 # handle a help for a command - either --help or no action triggers this
274- if (
275- parsed .command is not None
276- and parsed .action is None
277- ):
287+ if parsed .command is not None and parsed .action is None :
278288 if parsed .command in cli .ops :
279289 print_help_command_actions (cli .ops , parsed .command )
280290 sys .exit (ExitCodes .SUCCESS )
281291 if parsed .command in cli .config .get_custom_aliases ().keys ():
282- print_help_command_actions (cli .ops , cli .config .get_custom_aliases ()[parsed .command ])
292+ print_help_command_actions (
293+ cli .ops , cli .config .get_custom_aliases ()[parsed .command ]
294+ )
283295
284296 if parsed .command is not None and parsed .action is not None :
285297 if parsed .help :
286298 if parsed .command in cli .config .get_custom_aliases ().keys ():
287- print_help_action (cli , cli .config .get_custom_aliases ()[parsed .command ], parsed .action )
299+ print_help_action (
300+ cli ,
301+ cli .config .get_custom_aliases ()[parsed .command ],
302+ parsed .action ,
303+ )
288304 else :
289305 print_help_action (cli , parsed .command , parsed .action )
290306 sys .exit (ExitCodes .SUCCESS )
0 commit comments