diff --git a/crawl.py b/crawl.py index 4d1c6d7..18a9877 100755 --- a/crawl.py +++ b/crawl.py @@ -79,20 +79,24 @@ def _process_stdin(argv: str, res: utils.CurrencyResult) -> None: sys.exit() elif argv[0] in ['date', 'd']: print(res.date) - elif is_float(argv[0]): - # amount first -> convert to currency in argv[1] - print(fmt_and_calc( - cur=argv[1].upper(), - amt=float(argv[0]), - res=res, - direction=DIRECTION_FROM_EUR)) - elif is_float(argv[1]): - # currency first -> convert to EUR - print(fmt_and_calc( - cur=argv[0].upper(), - amt=float(argv[1]), - res=res, - direction=DIRECTION_TO_EUR)) + elif len(argv[0])==3 or len(argv[1])==3: + # more than 3 letter abbreviations are invalid + if is_float(argv[0]): + # amount first -> convert to currency in argv[1] + print(fmt_and_calc( + cur=argv[1].upper(), + amt=float(argv[0]), + res=res, + direction=DIRECTION_FROM_EUR)) + elif is_float(argv[1]): + # currency first -> convert to EUR + print(fmt_and_calc( + cur=argv[0].upper(), + amt=float(argv[1]), + res=res, + direction=DIRECTION_TO_EUR)) + else: + print("Not implemented: '" + " ".join(argv) + "'") except IndexError: if argv is None: pass