@@ -36,6 +36,10 @@ def main():
3636 if args .new_secrets_data :
3737 return pw .add_new_secrets_data ()
3838
39+ # pw -u <key>=<value> <entity>
40+ if args .update :
41+ return pw .update_secrets_data ()
42+
3943 # pw -rm <entity>
4044 if args .remove_entity :
4145 return pw .remove_secrets_data ()
@@ -101,15 +105,16 @@ def parse_args():
101105 parser .add_argument ('-ks' , '--available_keys' , action = 'store_true' )
102106 parser .add_argument ('-e' , '--expressive' , action = 'store_true' )
103107 parser .add_argument ('-as' , '--all_sections' , action = 'store_true' , help = h .all_sections )
104- parser .add_argument ('-s' , '--section' , type = str , help = h .section )
108+ parser .add_argument ('-s' , '--section' , type = str , default = 'main' , help = h .section )
105109
106110 parser .add_argument ('-r' , '--generate_random_pw' , action = 'store_true' , help = h .generate_random_pw )
107111 parser .add_argument ('-rl' , '--random_password_length' , type = int , default = 42 )
108112 parser .add_argument ('-rn' , '--no_special_characters' , action = 'store_false' )
109113
110114 parser .add_argument ('-n' , '--new_secrets_data' , type = str , help = h .add_new_password )
115+ parser .add_argument ('-u' , '--update' , type = str )
111116 parser .add_argument ('-pw' , '--set_password' , type = str , help = h .set_password )
112- parser .add_argument ('-u ' , '--username' , type = str )
117+ parser .add_argument ('-un ' , '--username' , type = str )
113118 parser .add_argument ('-w' , '--website' , type = str )
114119 parser .add_argument ('-kwargs' , '--kwargs' , '--keyword_arguments' , type = str )
115120 parser .add_argument ('-ow' , '--overwrite' , action = 'store_false' )
@@ -180,6 +185,15 @@ def add_new_secrets_data(self):
180185
181186 return True
182187
188+ def update_secrets_data (self ):
189+ """`pw -u <key>=<value> <entity>`"""
190+ k , v = self .args .update .split ('=' )
191+ new_data = {k : self .crypto .encrypt (v )}
192+ self .pw_client .update_secrets_data (
193+ entity = self .args .entity ,
194+ section = self .args .section ,
195+ new_data = new_data )
196+
183197 def get_secrets_data (self ):
184198 secrets_data = self .pw_client .get_secrets_data (
185199 entity = self .args .entity ,
0 commit comments