@@ -150,8 +150,10 @@ def register_command_info(aliases, command_info):
150
150
prog = 'clipboard-copy' , description = 'Retrieve the password for a specific record.' )
151
151
clipboard_copy_parser .add_argument ('--username' , dest = 'username' , action = 'store' , help = 'match login name (optional)' )
152
152
clipboard_copy_parser .add_argument (
153
- '--output' , dest = 'output' , choices = ['clipboard' , 'stdout' , 'stdouthidden' ], default = 'clipboard' , action = 'store' ,
153
+ '--output' , dest = 'output' , choices = ['clipboard' , 'stdout' , 'stdouthidden' , 'variable' ], default = 'clipboard' , action = 'store' ,
154
154
help = 'password output destination' )
155
+ clipboard_copy_parser .add_argument (
156
+ '--name' , dest = 'name' , action = 'store' , help = 'Variable name if output is set to variable' )
155
157
clipboard_copy_parser .add_argument (
156
158
'-cu' , '--copy-uid' , dest = 'copy_uid' , action = 'store_true' , help = 'output uid instead of password' )
157
159
clipboard_copy_parser .add_argument (
@@ -1894,6 +1896,12 @@ def execute(self, params, **kwargs):
1894
1896
logging .info (f'{ copy_item } copied to clipboard' )
1895
1897
elif kwargs ['output' ] == 'stdouthidden' :
1896
1898
print (f'{ Fore .RED } { Back .RED } { txt } { Style .RESET_ALL } ' )
1899
+ elif kwargs ['output' ] == 'variable' :
1900
+ var_name = kwargs .get ('name' )
1901
+ if not var_name :
1902
+ raise CommandError ('' , '"name" parameter is required when "output" is set to "variable"' )
1903
+ params .environment_variables [var_name ] = txt
1904
+ logging .info (f'{ copy_item } is set to variable "{ var_name } "' )
1897
1905
else :
1898
1906
print (txt )
1899
1907
0 commit comments