Mercurial > piecrust2
diff piecrust/commands/builtin/scaffolding.py @ 774:2bb3c1a04e98
prepare: Add ablity to run an editor program after creating the page file.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 03 Jul 2016 16:44:18 -0700 |
parents | 87f1e79d3fbe |
children | 4850f8c21b6e |
line wrap: on
line diff
--- a/piecrust/commands/builtin/scaffolding.py Sun Jul 03 15:56:35 2016 -0700 +++ b/piecrust/commands/builtin/scaffolding.py Sun Jul 03 16:44:18 2016 -0700 @@ -114,6 +114,24 @@ with open(path, 'w') as f: f.write(tpl_text) + editor = ctx.app.config.get('prepare/editor') + editor_type = ctx.app.config.get('prepare/editor_type', 'exe') + if editor: + import shlex + shell = False + args = '%s "%s"' % (editor, path) + if '%path%' in editor: + args = editor.replace('%path%', path) + + if editor_type.lower() == 'shell': + shell = True + else: + args = shlex.split(args) + + import subprocess + logger.info("Running: %s" % args) + subprocess.Popen(args, shell=shell) + class DefaultPrepareTemplatesCommandExtension(ChefCommandExtension): """ Provides the default scaffolding templates to the `prepare`