Skip to content

Commit

Permalink
clipboard-copy command to support a new target: variable. KC-836
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-keeper committed Dec 27, 2024
1 parent 21dcf6a commit c9f5650
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion keepercommander/commands/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ def register_command_info(aliases, command_info):
prog='clipboard-copy', description='Retrieve the password for a specific record.')
clipboard_copy_parser.add_argument('--username', dest='username', action='store', help='match login name (optional)')
clipboard_copy_parser.add_argument(
'--output', dest='output', choices=['clipboard', 'stdout', 'stdouthidden'], default='clipboard', action='store',
'--output', dest='output', choices=['clipboard', 'stdout', 'stdouthidden', 'variable'], default='clipboard', action='store',
help='password output destination')
clipboard_copy_parser.add_argument(
'--name', dest='name', action='store', help='Variable name if output is set to variable')
clipboard_copy_parser.add_argument(
'-cu', '--copy-uid', dest='copy_uid', action='store_true', help='output uid instead of password')
clipboard_copy_parser.add_argument(
Expand Down Expand Up @@ -1894,6 +1896,12 @@ def execute(self, params, **kwargs):
logging.info(f'{copy_item} copied to clipboard')
elif kwargs['output'] == 'stdouthidden':
print(f'{Fore.RED}{Back.RED}{txt}{Style.RESET_ALL}')
elif kwargs['output'] == 'variable':
var_name = kwargs.get('name')
if not var_name:
raise CommandError('', '"name" parameter is required when "output" is set to "variable"')
params.environment_variables[var_name] = txt
logging.info(f'{copy_item} is set to variable "{var_name}"')
else:
print(txt)

Expand Down

0 comments on commit c9f5650

Please sign in to comment.