Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
skip_confirmation = False
for opt, arg in opts:
if opt in ('-h', '--help'):
return HelpCommand()
elif opt in('-v', '--version'):
return VersionCommand()
elif opt == '-c':
cmd = arg
elif opt == '-t':
title = arg
elif opt == '-y':
skip_confirmation = True
if command == 'rec':
return RecordCommand(config.api_url, config.api_token, cmd, title,
skip_confirmation)
elif command == 'auth':
return AuthCommand(config.api_url, config.api_token)
return ErrorCommand("'%s' is not an asciinema command" % command)
def rec_command(args, config):
api = Api(config.api_url, os.environ.get("USER"), config.api_token)
return RecordCommand(api, args.filename, args.command, args.title, args.yes, args.quiet, args.max_wait)
subparsers = parser.add_subparsers()
# create the parser for the "rec" command
parser_rec = subparsers.add_parser('rec', help='Record terminal session')
parser_rec.add_argument('--stdin', help='enable stdin recording, disabled by default', action='store_true', default=cfg.record_stdin)
parser_rec.add_argument('--append', help='append to existing recording', action='store_true', default=False)
parser_rec.add_argument('--raw', help='save only raw stdout output', action='store_true', default=False)
parser_rec.add_argument('--overwrite', help='overwrite the file if it already exists', action='store_true', default=False)
parser_rec.add_argument('-c', '--command', help='command to record, defaults to $SHELL', default=cfg.record_command)
parser_rec.add_argument('-e', '--env', help='list of environment variables to capture, defaults to ' + config.DEFAULT_RECORD_ENV, default=cfg.record_env)
parser_rec.add_argument('-t', '--title', help='title of the asciicast')
parser_rec.add_argument('-i', '--idle-time-limit', help='limit recorded idle time to given number of seconds', type=positive_float, default=maybe_str(cfg.record_idle_time_limit))
parser_rec.add_argument('-y', '--yes', help='answer "yes" to all prompts (e.g. upload confirmation)', action='store_true', default=cfg.record_yes)
parser_rec.add_argument('-q', '--quiet', help='be quiet, suppress all notices/warnings (implies -y)', action='store_true', default=cfg.record_quiet)
parser_rec.add_argument('filename', nargs='?', default='', help='filename/path to save the recording to')
parser_rec.set_defaults(cmd=RecordCommand)
# create the parser for the "play" command
parser_play = subparsers.add_parser('play', help='Replay terminal session')
parser_play.add_argument('-i', '--idle-time-limit', help='limit idle time during playback to given number of seconds', type=positive_float, default=maybe_str(cfg.play_idle_time_limit))
parser_play.add_argument('-s', '--speed', help='playback speedup (can be fractional)', type=positive_float, default=cfg.play_speed)
parser_play.add_argument('filename', help='local path, http/ipfs URL or "-" (read from stdin)')
parser_play.set_defaults(cmd=PlayCommand)
# create the parser for the "cat" command
parser_cat = subparsers.add_parser('cat', help='Print full output of terminal session')
parser_cat.add_argument('filename', help='local path, http/ipfs URL or "-" (read from stdin)')
parser_cat.set_defaults(cmd=CatCommand)
# create the parser for the "upload" command
parser_upload = subparsers.add_parser('upload', help='Upload locally saved terminal session to asciinema.org')
parser_upload.add_argument('filename', help='filename or path of local recording')
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
from asciinema.commands.record import RecordCommand
from asciinema.commands.command import Command
import asciinema.asciicast.v2 as v2
import asciinema.asciicast.raw as raw
import tempfile
import os
# Create subclass of RecordCommand to pass in arguments
class HelpMeRecord(RecordCommand):
def __init__(
self,
api,
filename=None,
quiet=False,
env=None,
env_whitelist="",
record_stdin=False,
command=None,
title="HelpMe Recording",
append=False,
overwrite=False,
record_raw=False,
):
# If no custom file selected, create for user