Mercurial > piecrust2
comparison piecrust/commands/builtin/util.py @ 663:3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 01 Mar 2016 22:27:28 -0800 |
parents | c2ca72fb7f0b |
children | 81d9c3a3a0b5 |
comparison
equal
deleted
inserted
replaced
662:cbd5cdec0695 | 663:3ceeca7bb71c |
---|---|
2 import os.path | 2 import os.path |
3 import shutil | 3 import shutil |
4 import codecs | 4 import codecs |
5 import logging | 5 import logging |
6 import yaml | 6 import yaml |
7 from piecrust.app import CONFIG_PATH | 7 from piecrust.app import CONFIG_PATH, THEME_CONFIG_PATH |
8 from piecrust.commands.base import ChefCommand | 8 from piecrust.commands.base import ChefCommand |
9 | 9 |
10 | 10 |
11 logger = logging.getLogger(__name__) | 11 logger = logging.getLogger(__name__) |
12 | 12 |
17 self.name = 'init' | 17 self.name = 'init' |
18 self.description = "Creates a new empty PieCrust website." | 18 self.description = "Creates a new empty PieCrust website." |
19 self.requires_website = False | 19 self.requires_website = False |
20 | 20 |
21 def setupParser(self, parser, app): | 21 def setupParser(self, parser, app): |
22 parser.add_argument('destination', | 22 parser.add_argument( |
23 'destination', | |
23 help="The destination directory in which to create the website.") | 24 help="The destination directory in which to create the website.") |
24 | 25 |
25 def run(self, ctx): | 26 def run(self, ctx): |
26 destination = ctx.args.destination | 27 destination = ctx.args.destination |
27 if destination is None: | 28 if destination is None: |
29 | 30 |
30 if not os.path.isdir(destination): | 31 if not os.path.isdir(destination): |
31 os.makedirs(destination, 0o755) | 32 os.makedirs(destination, 0o755) |
32 | 33 |
33 config_path = os.path.join(destination, CONFIG_PATH) | 34 config_path = os.path.join(destination, CONFIG_PATH) |
35 if ctx.args.theme: | |
36 config_path = os.path.join(destination, THEME_CONFIG_PATH) | |
37 | |
34 if not os.path.isdir(os.path.dirname(config_path)): | 38 if not os.path.isdir(os.path.dirname(config_path)): |
35 os.makedirs(os.path.dirname(config_path), 0o755) | 39 os.makedirs(os.path.dirname(config_path), 0o755) |
36 | 40 |
37 config_text = yaml.dump({ | 41 config_text = yaml.dump({ |
38 'site': { | 42 'site': { |