Mercurial > piecrust2
diff piecrust/commands/base.py @ 1:aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Added `init` command.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 22 Dec 2013 08:00:24 -0800 |
parents | a212a3f2e3ee |
children | f485ba500df3 |
line wrap: on
line diff
--- a/piecrust/commands/base.py Sat Dec 21 14:44:02 2013 -0800 +++ b/piecrust/commands/base.py Sun Dec 22 08:00:24 2013 -0800 @@ -1,13 +1,14 @@ import logging +from piecrust.pathutil import SiteNotFoundError logger = logging.getLogger(__name__) class CommandContext(object): - def __init__(self, args, app): + def __init__(self, app, args): + self.app = app self.args = args - self.app = app class ChefCommand(object): @@ -22,16 +23,8 @@ def run(self, ctx): raise NotImplementedError() - -class RootCommand(ChefCommand): - def __init__(self): - super(RootCommand, self).__init__() - self.name = 'root' - self.description = "Gets the root directory of the current website." + def _runFromChef(self, app, res): + if app.root is None and self.requires_website: + raise SiteNotFoundError() + self.run(CommandContext(app, res)) - def setupParser(self, parser): - pass - - def run(self, ctx): - logger.info(ctx.app.root) -