Mercurial > piecrust2
changeset 773:87f1e79d3fbe
prepare: Use the same convention as other commands with sub-commands.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 03 Jul 2016 15:56:35 -0700 |
parents | 3885421c29a3 |
children | 2bb3c1a04e98 |
files | piecrust/commands/builtin/scaffolding.py |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/commands/builtin/scaffolding.py Sun Jul 03 07:54:54 2016 -0700 +++ b/piecrust/commands/builtin/scaffolding.py Sun Jul 03 15:56:35 2016 -0700 @@ -56,8 +56,18 @@ "generated text and header. Run `chef help " "scaffolding` for more information.") p.set_defaults(source=src) + p.set_defaults(sub_func=self._doRun) - def run(self, ctx): + def checkedRun(self, ctx): + if ctx.app.root_dir is None: + raise SiteNotFoundError(theme=ctx.app.theme_site) + + if not hasattr(ctx.args, 'sub_func'): + ctx.parser.parse_args(['prepare', '--help']) + return + ctx.args.sub_func(ctx) + + def _doRun(self, ctx): if not hasattr(ctx.args, 'source'): raise Exception("No source specified. " "Please run `chef prepare -h` for usage.")