Skip to content

Commit

Permalink
cli func to return exit status code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt committed Jan 3, 2017
1 parent 9276bff commit 4b6c048
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions jinja2cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ def cli(opts, args):
data = data[section]
else:
sys.stderr.write('ERROR: unknown section. Exiting.')
sys.exit(1)
return 1

output = render(template_path, data, extensions, opts.strict)

if isinstance(output, binary_type):
output = output.decode('utf-8')
sys.stdout.write(output)
sys.exit(0)
return 0


def parse_kv_string(pairs):
Expand Down Expand Up @@ -332,8 +332,7 @@ def main():
if opts.format not in formats and opts.format != 'auto':
raise InvalidDataFormat(opts.format)

cli(opts, args)
sys.exit(0)
sys.exit(cli(opts, args))


if __name__ == '__main__':
Expand Down

0 comments on commit 4b6c048

Please sign in to comment.