mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Make 'cat' subcommand be capable to actually concatenate multiple recordings
This commit is contained in:
@@ -222,10 +222,10 @@ For help on a specific command run:
|
|||||||
|
|
||||||
# create the parser for the `cat` command
|
# create the parser for the `cat` command
|
||||||
parser_cat = subparsers.add_parser(
|
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(
|
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)
|
parser_cat.set_defaults(cmd=CatCommand)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from .command import Command
|
|||||||
class CatCommand(Command):
|
class CatCommand(Command):
|
||||||
def __init__(self, args: Any, config: Config, env: Dict[str, str]):
|
def __init__(self, args: Any, config: Config, env: Dict[str, str]):
|
||||||
Command.__init__(self, args, config, env)
|
Command.__init__(self, args, config, env)
|
||||||
self.filename = args.filename
|
self.filenames = args.filename
|
||||||
|
|
||||||
def execute(self) -> int:
|
def execute(self) -> int:
|
||||||
try:
|
try:
|
||||||
@@ -22,10 +22,11 @@ class CatCommand(Command):
|
|||||||
|
|
||||||
def cat(self) -> int:
|
def cat(self) -> int:
|
||||||
try:
|
try:
|
||||||
with asciicast.open_from_url(self.filename) as a:
|
for filename in self.filenames:
|
||||||
for _, _type, text in a.events("o"):
|
with asciicast.open_from_url(filename) as a:
|
||||||
sys.stdout.write(text)
|
for _, _type, text in a.events("o"):
|
||||||
sys.stdout.flush()
|
sys.stdout.write(text)
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
except asciicast.LoadError as e:
|
except asciicast.LoadError as e:
|
||||||
self.print_error(f"printing failed: {str(e)}")
|
self.print_error(f"printing failed: {str(e)}")
|
||||||
|
|||||||
Reference in New Issue
Block a user