33from getpass import getpass
44
55import code42cli .profile as cliprofile
6- from code42cli .args import PROFILE_HELP
6+ from code42cli .args import PROFILE_HELP , ArgConfig
77from code42cli .commands import Command
88from code42cli .sdk_client import validate_connection
99from code42cli .util import does_user_agree , print_error , print_no_existing_profile_message
@@ -18,7 +18,7 @@ def load_subcommands():
1818 u"Print the details of a profile." ,
1919 u"{} {}" .format (usage_prefix , u"show <optional-args>" ),
2020 handler = show_profile ,
21- arg_customizer = _load_profile_description ,
21+ arg_customizer = _load_optional_profile_description ,
2222 )
2323
2424 list_all = Command (
@@ -40,7 +40,7 @@ def load_subcommands():
4040 u"Change the stored password for a profile." ,
4141 u"{} {}" .format (usage_prefix , u"reset-pw <optional-args>" ),
4242 handler = prompt_for_password_reset ,
43- arg_customizer = _load_profile_description ,
43+ arg_customizer = _load_optional_profile_description ,
4444 )
4545
4646 create = Command (
@@ -62,9 +62,9 @@ def load_subcommands():
6262 return [show , list_all , use , reset_pw , create , update ]
6363
6464
65- def show_profile (profile = None ):
65+ def show_profile (name = None ):
6666 """Prints the given profile to stdout."""
67- c42profile = cliprofile .get_profile (profile )
67+ c42profile = cliprofile .get_profile (name )
6868 print (u"\n {0}:" .format (c42profile .name ))
6969 print (u"\t * username = {}" .format (c42profile .username ))
7070 print (u"\t * authority url = {}" .format (c42profile .authority_url ))
@@ -79,15 +79,15 @@ def create_profile(profile, server, username, disable_ssl_errors=False):
7979 _prompt_for_allow_password_set (profile )
8080
8181
82- def update_profile (profile = None , server = None , username = None , disable_ssl_errors = None ):
83- profile = cliprofile .get_profile (profile )
82+ def update_profile (name = None , server = None , username = None , disable_ssl_errors = None ):
83+ profile = cliprofile .get_profile (name )
8484 cliprofile .update_profile (profile .name , server , username , disable_ssl_errors )
8585 _prompt_for_allow_password_set (profile .name )
8686
8787
88- def prompt_for_password_reset (profile = None ):
88+ def prompt_for_password_reset (name = None ):
8989 """Securely prompts for your password and then stores it using keyring."""
90- c42profile = cliprofile .get_profile (profile )
90+ c42profile = cliprofile .get_profile (name )
9191 new_password = getpass ()
9292 _validate_connection (c42profile .authority_url , c42profile .username , new_password )
9393 cliprofile .set_password (new_password , c42profile .name )
@@ -117,20 +117,20 @@ def use_profile(profile):
117117 cliprofile .switch_default_profile (profile )
118118
119119
120- def _load_profile_description (argument_collection ):
121- profile = argument_collection .arg_configs [u"profile" ]
120+ def _load_optional_profile_description (argument_collection ):
121+ profile = argument_collection .arg_configs [u"name" ]
122+ profile .add_short_option_name (u"-n" )
122123 profile .set_help (PROFILE_HELP )
123124
124125
125126def _load_profile_create_descriptions (argument_collection ):
126127 profile = argument_collection .arg_configs [u"profile" ]
127- profile .set_help (u"The name to give the profile being created." )
128+ profile .set_help (PROFILE_HELP )
128129 _load_profile_settings_descriptions (argument_collection )
129130
130131
131132def _load_profile_update_descriptions (argument_collection ):
132- profile = argument_collection .arg_configs [u"profile" ]
133- profile .set_help (u"The name to give the profile being updated." )
133+ _load_optional_profile_description (argument_collection )
134134 _load_profile_settings_descriptions (argument_collection )
135135 argument_collection .arg_configs [u"server" ].add_short_option_name (u"-s" )
136136 argument_collection .arg_configs [u"username" ].add_short_option_name (u"-u" )
0 commit comments