@@ -30,15 +30,19 @@ def remove_command(self, command_name):
3030 """
3131 Returns the command if it exists and has been passed to the console, otherwise it will print the help for the sample and exit the application.
3232 """
33- def get_command_required (self , command_name , message = None ):
33+ def get_command_required (self , command_name , command_name_alt = None ):
34+ if (command_name_alt != None ):
35+ if hasattr (self .parsed_commands , command_name_alt ):
36+ if (getattr (self .parsed_commands , command_name_alt ) != None ):
37+ return getattr (self .parsed_commands , command_name_alt )
38+
3439 if hasattr (self .parsed_commands , command_name ):
35- return getattr (self .parsed_commands , command_name )
36- else :
37- self .parser .print_help ()
38- print ("Command --" + command_name + " required." )
39- if message is not None :
40- print (message )
41- exit ()
40+ if (getattr (self .parsed_commands , command_name ) != None ):
41+ return getattr (self .parsed_commands , command_name )
42+
43+ self .parser .print_help ()
44+ print ("Command --" + command_name + " required." )
45+ exit ()
4246
4347 """
4448 Returns the command if it exists, has been passed to the console, and is not None. Otherwise it returns whatever is passed as the default.
@@ -68,6 +72,7 @@ def get_args(self):
6872 # Automatically start logging if it is set
6973 if self .parsed_commands .verbosity :
7074 io .init_logging (getattr (io .LogLevel , self .parsed_commands .verbosity ), 'stderr' )
75+
7176 return self .parsed_commands
7277
7378 def update_command (self , command_name , new_example_input = None , new_help_output = None , new_required = None , new_type = None , new_default = None , new_action = None ):
@@ -357,7 +362,7 @@ def parse_sample_input_basic_discovery():
357362 cmdData .input_ca = cmdUtils .get_command (CommandLineUtils .m_cmd_ca_file , None )
358363 cmdData .input_thing_name = cmdUtils .get_command_required (CommandLineUtils .m_cmd_thing_name )
359364 cmdData .input_mode = cmdUtils .get_command (CommandLineUtils .m_cmd_mode , "both" )
360- cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_region )
365+ cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_region , CommandLineUtils . m_cmd_signing_region )
361366 cmdData .input_max_pub_ops = int (cmdUtils .get_command (CommandLineUtils .m_cmd_max_pub_ops , 10 ))
362367 cmdData .input_print_discovery_resp_only = bool (cmdUtils .get_command (CommandLineUtils .m_cmd_print_discovery_resp_only , False ))
363368 cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
@@ -372,7 +377,10 @@ def parse_sample_input_cognito_connect():
372377 cmdUtils .add_common_logging_commands ()
373378 cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
374379 "The signing region used for the websocket signer" ,
375- True , str )
380+ False , str )
381+ cmdUtils .register_command (CommandLineUtils .m_cmd_region , "<str>" ,
382+ "The signing region used for the websocket signer" ,
383+ False , str )
376384 cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
377385 "Client ID to use for MQTT connection (optional, default='test-*')." ,
378386 default = "test-" + str (uuid4 ()))
@@ -383,7 +391,7 @@ def parse_sample_input_cognito_connect():
383391
384392 cmdData = CommandLineUtils .CmdData ()
385393 cmdData .input_endpoint = cmdUtils .get_command_required (CommandLineUtils .m_cmd_endpoint )
386- cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region )
394+ cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region , CommandLineUtils . m_cmd_region )
387395 cmdData .input_cognito_identity = cmdUtils .get_command_required (CommandLineUtils .m_cmd_cognito_identity )
388396 cmdData .input_clientId = cmdUtils .get_command (CommandLineUtils .m_cmd_client_id , "test-" + str (uuid4 ()))
389397 cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
@@ -399,15 +407,18 @@ def parse_sample_input_custom_authorizer_connect():
399407 cmdUtils .add_common_custom_authorizer_commands ()
400408 cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
401409 "The signing region used for the websocket signer" ,
402- True , str )
410+ False , str )
411+ cmdUtils .register_command (CommandLineUtils .m_cmd_region , "<str>" ,
412+ "The signing region used for the websocket signer" ,
413+ False , str )
403414 cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
404415 "Client ID to use for MQTT connection (optional, default='test-*')." ,
405416 default = "test-" + str (uuid4 ()))
406417 cmdUtils .get_args ()
407418
408419 cmdData = CommandLineUtils .CmdData ()
409420 cmdData .input_endpoint = cmdUtils .get_command_required (CommandLineUtils .m_cmd_endpoint )
410- cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region )
421+ cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region , CommandLineUtils . m_cmd_region )
411422 cmdData .input_custom_authorizer_name = cmdUtils .get_command (CommandLineUtils .m_cmd_custom_auth_authorizer_name )
412423 cmdData .input_custom_authorizer_signature = cmdUtils .get_command (CommandLineUtils .m_cmd_custom_auth_authorizer_signature )
413424 cmdData .input_custom_auth_password = cmdUtils .get_command (CommandLineUtils .m_cmd_custom_auth_password )
@@ -731,15 +742,18 @@ def parse_sample_input_websocket_connect():
731742 cmdUtils .add_common_logging_commands ()
732743 cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
733744 "The signing region used for the websocket signer" ,
734- True , str )
745+ False , str )
746+ cmdUtils .register_command (CommandLineUtils .m_cmd_region , "<str>" ,
747+ "The signing region used for the websocket signer" ,
748+ False , str )
735749 cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
736750 "Client ID to use for MQTT connection (optional, default='test-*')." ,
737751 default = "test-" + str (uuid4 ()))
738752 cmdUtils .get_args ()
739753
740754 cmdData = CommandLineUtils .CmdData ()
741755 cmdData .input_endpoint = cmdUtils .get_command_required (CommandLineUtils .m_cmd_endpoint )
742- cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region )
756+ cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region , CommandLineUtils . m_cmd_region )
743757 cmdData .input_clientId = cmdUtils .get_command (CommandLineUtils .m_cmd_client_id , "test-" + str (uuid4 ()))
744758 cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
745759 cmdData .input_proxy_port = int (cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_port ))
@@ -775,15 +789,18 @@ def parse_sample_input_x509_connect():
775789 cmdUtils .add_common_x509_commands ()
776790 cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
777791 "The signing region used for the websocket signer" ,
778- True , str )
792+ False , str )
793+ cmdUtils .register_command (CommandLineUtils .m_cmd_region , "<str>" ,
794+ "The signing region used for the websocket signer" ,
795+ False , str )
779796 cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
780797 "Client ID to use for MQTT connection (optional, default='test-*')." ,
781798 default = "test-" + str (uuid4 ()))
782799 cmdUtils .get_args ()
783800
784801 cmdData = CommandLineUtils .CmdData ()
785802 cmdData .input_endpoint = cmdUtils .get_command_required (CommandLineUtils .m_cmd_endpoint )
786- cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region )
803+ cmdData .input_signing_region = cmdUtils .get_command_required (CommandLineUtils .m_cmd_signing_region , CommandLineUtils . m_cmd_region )
787804 cmdData .input_clientId = cmdUtils .get_command (CommandLineUtils .m_cmd_client_id , "test-" + str (uuid4 ()))
788805 cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
789806 cmdData .input_proxy_port = int (cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_port ))
0 commit comments