mirror of
https://github.com/httpie/cli.git
synced 2024-11-22 07:43:20 +01:00
Exit with 0 for --version and --help (closes #293).
This commit is contained in:
parent
0481957715
commit
b2ec4f797f
@ -163,12 +163,17 @@ def main(args=sys.argv[1:], env=Environment()):
|
|||||||
env.stderr.write('\n')
|
env.stderr.write('\n')
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except KeyboardInterrupt:
|
||||||
if traceback:
|
if traceback:
|
||||||
raise
|
raise
|
||||||
env.stderr.write('\n')
|
env.stderr.write('\n')
|
||||||
exit_status = ExitStatus.ERROR
|
exit_status = ExitStatus.ERROR
|
||||||
|
except SystemExit as e:
|
||||||
|
if e.code != ExitStatus.OK:
|
||||||
|
if traceback:
|
||||||
|
raise
|
||||||
|
env.stderr.write('\n')
|
||||||
|
exit_status = ExitStatus.ERROR
|
||||||
except requests.Timeout:
|
except requests.Timeout:
|
||||||
exit_status = ExitStatus.ERROR_TIMEOUT
|
exit_status = ExitStatus.ERROR_TIMEOUT
|
||||||
error('Request timed out (%ss).', args.timeout)
|
error('Request timed out (%ss).', args.timeout)
|
||||||
|
@ -14,12 +14,12 @@ class TestHTTPie:
|
|||||||
|
|
||||||
def test_help(self):
|
def test_help(self):
|
||||||
r = http('--help', error_exit_ok=True)
|
r = http('--help', error_exit_ok=True)
|
||||||
assert r.exit_status == httpie.ExitStatus.ERROR
|
assert r.exit_status == httpie.ExitStatus.OK
|
||||||
assert 'https://github.com/jakubroztocil/httpie/issues' in r
|
assert 'https://github.com/jakubroztocil/httpie/issues' in r
|
||||||
|
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
r = http('--version', error_exit_ok=True)
|
r = http('--version', error_exit_ok=True)
|
||||||
assert r.exit_status == httpie.ExitStatus.ERROR
|
assert r.exit_status == httpie.ExitStatus.OK
|
||||||
# FIXME: py3 has version in stdout, py2 in stderr
|
# FIXME: py3 has version in stdout, py2 in stderr
|
||||||
assert httpie.__version__ == r.stderr.strip() + r.strip()
|
assert httpie.__version__ == r.stderr.strip() + r.strip()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user