@@ -30,15 +30,19 @@ def remove_command(self, command_name):
30
30
"""
31
31
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.
32
32
"""
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
+
34
39
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 ()
42
46
43
47
"""
44
48
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):
68
72
# Automatically start logging if it is set
69
73
if self .parsed_commands .verbosity :
70
74
io .init_logging (getattr (io .LogLevel , self .parsed_commands .verbosity ), 'stderr' )
75
+
71
76
return self .parsed_commands
72
77
73
78
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():
357
362
cmdData .input_ca = cmdUtils .get_command (CommandLineUtils .m_cmd_ca_file , None )
358
363
cmdData .input_thing_name = cmdUtils .get_command_required (CommandLineUtils .m_cmd_thing_name )
359
364
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 )
361
366
cmdData .input_max_pub_ops = int (cmdUtils .get_command (CommandLineUtils .m_cmd_max_pub_ops , 10 ))
362
367
cmdData .input_print_discovery_resp_only = bool (cmdUtils .get_command (CommandLineUtils .m_cmd_print_discovery_resp_only , False ))
363
368
cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
@@ -372,7 +377,10 @@ def parse_sample_input_cognito_connect():
372
377
cmdUtils .add_common_logging_commands ()
373
378
cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
374
379
"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 )
376
384
cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
377
385
"Client ID to use for MQTT connection (optional, default='test-*')." ,
378
386
default = "test-" + str (uuid4 ()))
@@ -383,7 +391,7 @@ def parse_sample_input_cognito_connect():
383
391
384
392
cmdData = CommandLineUtils .CmdData ()
385
393
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 )
387
395
cmdData .input_cognito_identity = cmdUtils .get_command_required (CommandLineUtils .m_cmd_cognito_identity )
388
396
cmdData .input_clientId = cmdUtils .get_command (CommandLineUtils .m_cmd_client_id , "test-" + str (uuid4 ()))
389
397
cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
@@ -399,15 +407,18 @@ def parse_sample_input_custom_authorizer_connect():
399
407
cmdUtils .add_common_custom_authorizer_commands ()
400
408
cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
401
409
"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 )
403
414
cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
404
415
"Client ID to use for MQTT connection (optional, default='test-*')." ,
405
416
default = "test-" + str (uuid4 ()))
406
417
cmdUtils .get_args ()
407
418
408
419
cmdData = CommandLineUtils .CmdData ()
409
420
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 )
411
422
cmdData .input_custom_authorizer_name = cmdUtils .get_command (CommandLineUtils .m_cmd_custom_auth_authorizer_name )
412
423
cmdData .input_custom_authorizer_signature = cmdUtils .get_command (CommandLineUtils .m_cmd_custom_auth_authorizer_signature )
413
424
cmdData .input_custom_auth_password = cmdUtils .get_command (CommandLineUtils .m_cmd_custom_auth_password )
@@ -731,15 +742,18 @@ def parse_sample_input_websocket_connect():
731
742
cmdUtils .add_common_logging_commands ()
732
743
cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
733
744
"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 )
735
749
cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
736
750
"Client ID to use for MQTT connection (optional, default='test-*')." ,
737
751
default = "test-" + str (uuid4 ()))
738
752
cmdUtils .get_args ()
739
753
740
754
cmdData = CommandLineUtils .CmdData ()
741
755
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 )
743
757
cmdData .input_clientId = cmdUtils .get_command (CommandLineUtils .m_cmd_client_id , "test-" + str (uuid4 ()))
744
758
cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
745
759
cmdData .input_proxy_port = int (cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_port ))
@@ -775,15 +789,18 @@ def parse_sample_input_x509_connect():
775
789
cmdUtils .add_common_x509_commands ()
776
790
cmdUtils .register_command (CommandLineUtils .m_cmd_signing_region , "<str>" ,
777
791
"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 )
779
796
cmdUtils .register_command (CommandLineUtils .m_cmd_client_id , "<str>" ,
780
797
"Client ID to use for MQTT connection (optional, default='test-*')." ,
781
798
default = "test-" + str (uuid4 ()))
782
799
cmdUtils .get_args ()
783
800
784
801
cmdData = CommandLineUtils .CmdData ()
785
802
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 )
787
804
cmdData .input_clientId = cmdUtils .get_command (CommandLineUtils .m_cmd_client_id , "test-" + str (uuid4 ()))
788
805
cmdData .input_proxy_host = cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_host )
789
806
cmdData .input_proxy_port = int (cmdUtils .get_command (CommandLineUtils .m_cmd_proxy_port ))
0 commit comments