diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c62cdae09..54aac9fa3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,6 +67,10 @@ jobs: git --no-pager diff --numstat tests/ git --no-pager diff --exit-code tests/ + - name: Test replaying input from stdin + run: | + echo -e '{"a":1}\n{"a":2}' | vd -f jsonl -p dev/stdin.vdj --batch --debug -N + - name: Ensure VisiData can create completions run: python -v dev/zsh-completion.py diff --git a/dev/stdin.vdj b/dev/stdin.vdj new file mode 100644 index 000000000..aa66a4b8c --- /dev/null +++ b/dev/stdin.vdj @@ -0,0 +1,5 @@ +#!vd -p +{"sheet": "global", "col": null, "row": "regex_flags", "longname": "set-option", "input": "IS", "keystrokes": "", "comment": null, "replayable": null} +{"sheet": "global", "row": "filetype", "longname": "set-option", "input": "jsonl", "keystrokes": ""} +{"longname": "open-file", "input": "-", "keystrokes": "o", "replayable": true} +{"sheet": "-", "col": "", "row": "", "longname": "transpose", "input": "", "keystrokes": "Shift+T", "comment": "open new sheet with rows and columns transposed", "replayable": true} diff --git a/visidata/_open.py b/visidata/_open.py index 18d0a8d55..ff59013fe 100644 --- a/visidata/_open.py +++ b/visidata/_open.py @@ -155,7 +155,7 @@ def openSource(vd, p, filetype=None, create=False, **kwargs): if '://' in p: vs = vd.openPath(Path(p), filetype=filetype) # convert to Path and recurse elif p == '-': - if sys.stdin.isatty(): + if vd.stdinSource.fptext.isatty(): vd.fail('cannot open stdin when it is a tty') vs = vd.openPath(vd.stdinSource, filetype=filetype) else: diff --git a/visidata/main.py b/visidata/main.py index 91502c2ab..c3db16c60 100755 --- a/visidata/main.py +++ b/visidata/main.py @@ -344,6 +344,8 @@ def main_vd(): run(vd.sheets[0]) else: if args.play == '-': + if vd.stdinSource.fptext.isatty(): + vd.fail('replay commands must come by pipe, not by terminal') vdfile = vd.stdinSource else: vdfile = Path(args.play)