# HG changeset patch # User Ludovic Chabant # Date 1467586595 25200 # Node ID 87f1e79d3fbe93875f872b438b981441b7855e6f # Parent 3885421c29a35e284d63a2b5beaa35ab0a16ac96 prepare: Use the same convention as other commands with sub-commands. diff -r 3885421c29a3 -r 87f1e79d3fbe piecrust/commands/builtin/scaffolding.py --- 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.")