icat kitten: Add a --stdin option to control if image data is read from stdin
See #1308
This commit is contained in:
parent
f8f188ecff
commit
fa01e0b76f
@ -6,6 +6,9 @@ Changelog
|
|||||||
0.13.3 [future]
|
0.13.3 [future]
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
|
- icat kitten: Add a ``--stdin`` option to control if image data is read from
|
||||||
|
stdin (:iss:`1308`)
|
||||||
|
|
||||||
- hints kitten: Start hints numbering at one instead of zero by default. Added
|
- hints kitten: Start hints numbering at one instead of zero by default. Added
|
||||||
an option ``--hints-offset`` to control it. (:iss:`1289`)
|
an option ``--hints-offset`` to control it. (:iss:`1289`)
|
||||||
|
|
||||||
|
|||||||
@ -81,6 +81,14 @@ type=bool-set
|
|||||||
Print out the window size as :italic:`widthxheight` (in pixels) and quit. This is a
|
Print out the window size as :italic:`widthxheight` (in pixels) and quit. This is a
|
||||||
convenience method to query the window size if using kitty icat from a
|
convenience method to query the window size if using kitty icat from a
|
||||||
scripting language that cannot make termios calls.
|
scripting language that cannot make termios calls.
|
||||||
|
|
||||||
|
|
||||||
|
--stdin
|
||||||
|
type=choices
|
||||||
|
choices=detect,yes,no
|
||||||
|
default=detect
|
||||||
|
Read image data from stdin. The default is to do it automatically, when STDIN is not a terminal,
|
||||||
|
but you can turn it off or on explicitly, if needed.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
@ -269,8 +277,9 @@ def main(args=sys.argv):
|
|||||||
if not sys.stdout.isatty():
|
if not sys.stdout.isatty():
|
||||||
sys.stdout = open(os.ctermid(), 'w')
|
sys.stdout = open(os.ctermid(), 'w')
|
||||||
stdin_data = None
|
stdin_data = None
|
||||||
if not sys.stdin.isatty():
|
if args.stdin == 'yes' or (not sys.stdin.isatty() and args.stdin == 'detect'):
|
||||||
stdin_data = sys.stdin.buffer.read()
|
stdin_data = sys.stdin.buffer.read()
|
||||||
|
if stdin_data:
|
||||||
items.insert(0, stdin_data)
|
items.insert(0, stdin_data)
|
||||||
sys.stdin.close()
|
sys.stdin.close()
|
||||||
sys.stdin = open(os.ctermid(), 'r')
|
sys.stdin = open(os.ctermid(), 'r')
|
||||||
@ -307,7 +316,7 @@ def main(args=sys.argv):
|
|||||||
raise SystemExit('You must specify at least one file to cat')
|
raise SystemExit('You must specify at least one file to cat')
|
||||||
if args.place:
|
if args.place:
|
||||||
if len(items) > 1 or (isinstance(items[0], str) and os.path.isdir(items[0])):
|
if len(items) > 1 or (isinstance(items[0], str) and os.path.isdir(items[0])):
|
||||||
raise SystemExit('The --place option can only be used with a single image')
|
raise SystemExit(f'The --place option can only be used with a single image, not {items}')
|
||||||
sys.stdout.buffer.write(b'\0337') # save cursor
|
sys.stdout.buffer.write(b'\0337') # save cursor
|
||||||
for item in items:
|
for item in items:
|
||||||
is_tempfile = False
|
is_tempfile = False
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user