diff --git a/ui/fixtures/cmd.basic.json b/ui/fixtures/cmd.basic.json index 32af8ae..9da2e40 100644 --- a/ui/fixtures/cmd.basic.json +++ b/ui/fixtures/cmd.basic.json @@ -118,9 +118,10 @@ }, { "title": "test file is not present", - "cmd": [ "list", "test.txt" ], + "cmd": [ "list", "test.txt", "newfile.txt" ], "exit": 1, - "stderr": "ERROR: file not found: 'test.txt'\n" + "stderr": "ERROR: file not found: 'test.txt'\n", + "stdout_re": "foo:\tbar=baz\nhashes:\tsha512:90f8342520f0ac57fb5a779f5d331c2fa87aa40f8799940257f9ba619940951e67143a8d746535ed0284924b2b7bc1478f095198800ba96d01847d7b56ca465c\nsig:\t.*\ntag:\t\n" }, { "special": "copy newfile.txt to test.txt" diff --git a/ui/medashare/cli.py b/ui/medashare/cli.py index 4ef79a3..e710fc2 100644 --- a/ui/medashare/cli.py +++ b/ui/medashare/cli.py @@ -1377,6 +1377,7 @@ def cmd_auto(options): @init_datastructs def cmd_list(options, persona, objstr, cache): + exit = 0 for i in options.files: try: objs = objstr.by_file(i) @@ -1390,12 +1391,16 @@ def cmd_list(options, persona, objstr, cache): objs = objstr.by_file(i) except (FileNotFoundError, KeyError) as e: print('ERROR: file not found: %s' % repr(i), file=sys.stderr) - sys.exit(1) + exit = 1 + continue for j in objstr.by_file(i): for k, v in _iterdictlist(j): print('%s:\t%s' % (k, v)) + if exit: + sys.exit(exit) + def handle_bittorrent(fname, persona, objstr): with open(fname, 'rb') as fp: torrent = bencode.bdecode(fp.read())