Repository: frictionlessdata/goodtables-py

Issue:
Goodtable init command should return 0 on success
It should also use sys.exit() instead of exit()

Discussion:

Patch:
diff --git a/goodtables/cli.py b/goodtables/cli.py
index 6661cc8..186d227 100644
--- a/goodtables/cli.py
+++ b/goodtables/cli.py
@@ -4,6 +4,8 @@ from __future__ import print_function
 from __future__ import absolute_import
 from __future__ import unicode_literals
 
+from sys import exit
+
 import click
 import goodtables
 import json as json_module
@@ -113,7 +115,7 @@ def validate(paths, json, **options):
     if not quiet:
         _print_report(report, output=output, json=json)
 
-    exit(not report['valid'])
+    exit(int(not report['valid']))
 
 
 @cli.command()
@@ -137,7 +139,7 @@ def init(paths, output, **kwargs):
         file=output
     )
 
-    exit(dp.valid)  # Just to be defensive, as it should always be valid.
+    exit(int(not dp.valid))  # Just to be defensive, as it should always be valid.
 
 
 # Internal


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 3cfa96a..024a41e 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -50,7 +50,7 @@ def test_cli_init():
 
     result = CliRunner().invoke(init, [resource_path])
 
-    assert result.exit_code
+    assert result.exit_code == 0
 
     dp = datapackage.Package(json.loads(result.output), strict=True)
     resource = dp.resources[0]