Skip to content

Commit c9f5650

Browse files
committed
clipboard-copy command to support a new target: variable. KC-836
1 parent 21dcf6a commit c9f5650

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

keepercommander/commands/record.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ def register_command_info(aliases, command_info):
150150
prog='clipboard-copy', description='Retrieve the password for a specific record.')
151151
clipboard_copy_parser.add_argument('--username', dest='username', action='store', help='match login name (optional)')
152152
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',
154154
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')
155157
clipboard_copy_parser.add_argument(
156158
'-cu', '--copy-uid', dest='copy_uid', action='store_true', help='output uid instead of password')
157159
clipboard_copy_parser.add_argument(
@@ -1894,6 +1896,12 @@ def execute(self, params, **kwargs):
18941896
logging.info(f'{copy_item} copied to clipboard')
18951897
elif kwargs['output'] == 'stdouthidden':
18961898
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}"')
18971905
else:
18981906
print(txt)
18991907

0 commit comments

Comments
 (0)