Mercurial > piecrust2
changeset 384:d241585412ad
internal: Make it possible to pass `argv` to the main Chef function.
This makes it easy to write system tests against the CLI.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 11 May 2015 22:24:05 -0700 |
parents | 44cf6ce62467 |
children | 2d5f2289885a |
files | piecrust/main.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/main.py Sun May 10 23:34:50 2015 -0700 +++ b/piecrust/main.py Mon May 11 22:24:05 2015 -0700 @@ -60,10 +60,10 @@ except ValueError: locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') - argv = sys.argv + argv = sys.argv[1:] pre_args = _pre_parse_chef_args(argv) try: - exit_code = _run_chef(pre_args) + exit_code = _run_chef(pre_args, argv) except Exception as ex: if pre_args.debug: logger.exception(ex) @@ -100,7 +100,7 @@ # related arguments must be parsed first because we want to log everything # from the beginning. res = PreParsedChefArgs() - i = 1 + i = 0 while i < len(argv): arg = argv[i] if arg.startswith('--root='): @@ -166,7 +166,7 @@ return res -def _run_chef(pre_args): +def _run_chef(pre_args, argv): # Setup the app. start_time = time.clock() root = pre_args.root @@ -250,7 +250,7 @@ parser.epilog = epilog.getvalue() # Parse the command line. - result = parser.parse_args() + result = parser.parse_args(argv) logger.debug(format_timed(start_time, 'initialized PieCrust', colored=False))