Make 'cat' subcommand be capable to actually concatenate multiple recordings

This commit is contained in:
WHR
2023-06-27 09:16:18 +00:00
parent 61be1f8302
commit 2fcc4315be
2 changed files with 8 additions and 7 deletions

View File

@@ -222,10 +222,10 @@ For help on a specific command run:
# create the parser for the `cat` command
parser_cat = subparsers.add_parser(
"cat", help="Print full output of terminal session"
"cat", help="Print full output of terminal sessions"
)
parser_cat.add_argument(
"filename", help='local path, http/ipfs URL or "-" (read from stdin)'
"filename", nargs="+", help='local path, http/ipfs URL or "-" (read from stdin)'
)
parser_cat.set_defaults(cmd=CatCommand)

View File

@@ -10,7 +10,7 @@ from .command import Command
class CatCommand(Command):
def __init__(self, args: Any, config: Config, env: Dict[str, str]):
Command.__init__(self, args, config, env)
self.filename = args.filename
self.filenames = args.filename
def execute(self) -> int:
try:
@@ -22,7 +22,8 @@ class CatCommand(Command):
def cat(self) -> int:
try:
with asciicast.open_from_url(self.filename) as a:
for filename in self.filenames:
with asciicast.open_from_url(filename) as a:
for _, _type, text in a.events("o"):
sys.stdout.write(text)
sys.stdout.flush()