comparison piecrust/commands/builtin/scaffolding.py @ 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 03c3a77fda60
children 2bb3c1a04e98
comparison
equal deleted inserted replaced
772:3885421c29a3 773:87f1e79d3fbe
54 p.add_argument('-t', '--template', default='default', 54 p.add_argument('-t', '--template', default='default',
55 help="The template to use, which will change the " 55 help="The template to use, which will change the "
56 "generated text and header. Run `chef help " 56 "generated text and header. Run `chef help "
57 "scaffolding` for more information.") 57 "scaffolding` for more information.")
58 p.set_defaults(source=src) 58 p.set_defaults(source=src)
59 59 p.set_defaults(sub_func=self._doRun)
60 def run(self, ctx): 60
61 def checkedRun(self, ctx):
62 if ctx.app.root_dir is None:
63 raise SiteNotFoundError(theme=ctx.app.theme_site)
64
65 if not hasattr(ctx.args, 'sub_func'):
66 ctx.parser.parse_args(['prepare', '--help'])
67 return
68 ctx.args.sub_func(ctx)
69
70 def _doRun(self, ctx):
61 if not hasattr(ctx.args, 'source'): 71 if not hasattr(ctx.args, 'source'):
62 raise Exception("No source specified. " 72 raise Exception("No source specified. "
63 "Please run `chef prepare -h` for usage.") 73 "Please run `chef prepare -h` for usage.")
64 74
65 app = ctx.app 75 app = ctx.app