forked from solderpunk/AV-98
don’t crash ansicat if run without arguments
This commit is contained in:
parent
5bf84c91fa
commit
e7831338de
17
ansicat.py
17
ansicat.py
|
@ -1394,13 +1394,16 @@ def main():
|
|||
# Detect if we are running interactively or in a pipe
|
||||
if sys.stdin.isatty():
|
||||
#we are interactive, not in stdin, we can have multiple files as input
|
||||
for f in args.content:
|
||||
path = os.path.abspath(f.name)
|
||||
try:
|
||||
content = f.read()
|
||||
except UnicodeDecodeError:
|
||||
content = f
|
||||
render(content,path=path,format=args.format,url=args.url,mime=args.mime)
|
||||
if isinstance(args.content,list):
|
||||
for f in args.content:
|
||||
path = os.path.abspath(f.name)
|
||||
try:
|
||||
content = f.read()
|
||||
except UnicodeDecodeError:
|
||||
content = f
|
||||
render(content,path=path,format=args.format,url=args.url,mime=args.mime)
|
||||
else:
|
||||
print("Ansicat needs at least one file as an argument")
|
||||
else:
|
||||
#we are in stdin
|
||||
if not args.format and not args.mime:
|
||||
|
|
Loading…
Reference in New Issue