icat: Add --transfer-mode option

Explicitly control the transfer mode instead of auto-detecting
This commit is contained in:
Kovid Goyal 2017-12-15 13:34:39 +05:30
parent 304f21e79d
commit 50470b5747
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -46,6 +46,17 @@ type=choices
choices=center,left,right choices=center,left,right
default=center default=center
Horizontal alignment for the displayed image. Defaults to centered. Horizontal alignment for the displayed image. Defaults to centered.
--transfer-mode
type=choices
choices=detect,file,stream
default=detect
What mechanism to use to transfer images to the terminal. The default is to
auto-detect. |_ file| means to use a temporary file and |_ stream| means to
send the data via terminal escape codes. Note that if you use the |_ file|
transfer mode and you are connecting over a remote session then image display
will not work.
''' '''
@ -256,13 +267,16 @@ def main(args=sys.argv):
) )
msg = ( msg = (
'A cat like utility to display images in the terminal.' 'A cat like utility to display images in the terminal.'
' You can specify multiple images files and/or directories.' ' You can specify multiple image files and/or directories.'
' Directories are scanned recursively for image files.') ' Directories are scanned recursively for image files.')
args, items = parse_args(args[1:], options_spec, 'image-file ...', msg, '{} icat'.format(appname)) args, items = parse_args(args[1:], options_spec, 'image-file ...', msg, '{} icat'.format(appname))
if not items: if not items:
raise SystemExit('You must specify at least one file to cat') raise SystemExit('You must specify at least one file to cat')
if args.transfer_mode == 'detect':
if not detect_support(): if not detect_support():
raise SystemExit('This terminal emulator does not support the graphics protocol, use a terminal emulator such as kitty that does support it') raise SystemExit('This terminal emulator does not support the graphics protocol, use a terminal emulator such as kitty that does support it')
else:
detect_support.has_files = args.transfer_mode == 'file'
errors = [] errors = []
for item in items: for item in items:
try: try: