# HG changeset patch # User Ludovic Chabant # Date 1420176060 28800 # Node ID 6d23473fab415de41537527a1eba56c5ea4327e9 # Parent c4b155b08b52ae19e0265400f1501d713e4545f0 sources: Add `chef sources` command to list page sources. diff -r c4b155b08b52 -r 6d23473fab41 piecrust/commands/builtin/info.py --- a/piecrust/commands/builtin/info.py Thu Jan 01 21:10:46 2015 -0800 +++ b/piecrust/commands/builtin/info.py Thu Jan 01 21:21:00 2015 -0800 @@ -49,6 +49,22 @@ ctx.result = 1 +class ShowSourcesCommand(ChefCommand): + def __init__(self): + super(ShowSourcesCommand, self).__init__() + self.name = 'sources' + self.description = "Shows the sources defined for this website." + + def setupParser(self, parser, app): + pass + + def run(self, ctx): + for src in ctx.app.sources: + logger.info("%s:" % src.name) + logger.info(" type: %s" % src.config.get('type')) + logger.info(" class: %s" % type(src)) + + class ShowRoutesCommand(ChefCommand): def __init__(self): super(ShowRoutesCommand, self).__init__() diff -r c4b155b08b52 -r 6d23473fab41 piecrust/plugins/builtin.py --- a/piecrust/plugins/builtin.py Thu Jan 01 21:10:46 2015 -0800 +++ b/piecrust/plugins/builtin.py Thu Jan 01 21:21:00 2015 -0800 @@ -1,13 +1,16 @@ from piecrust.commands.base import HelpCommand -from piecrust.commands.builtin.baking import (BakeCommand, ShowRecordCommand) -from piecrust.commands.builtin.info import (RootCommand, ShowConfigCommand, - FindCommand, ShowRoutesCommand, ShowPathsCommand) -from piecrust.commands.builtin.scaffolding import (PrepareCommand, +from piecrust.commands.builtin.baking import ( + BakeCommand, ShowRecordCommand) +from piecrust.commands.builtin.info import ( + RootCommand, ShowConfigCommand, + FindCommand, ShowSourcesCommand, ShowRoutesCommand, ShowPathsCommand) +from piecrust.commands.builtin.scaffolding import ( + PrepareCommand, DefaultPrepareTemplatesCommandExtension, DefaultPrepareTemplatesHelpTopic) from piecrust.commands.builtin.serving import (ServeCommand) -from piecrust.commands.builtin.util import (InitCommand, PurgeCommand, - ImportCommand) +from piecrust.commands.builtin.util import ( + InitCommand, PurgeCommand, ImportCommand) from piecrust.data.provider import (IteratorDataProvider, BlogDataProvider) from piecrust.formatting.markdownformatter import MarkdownFormatter from piecrust.formatting.textileformatter import TextileFormatter @@ -20,8 +23,8 @@ from piecrust.processing.requirejs import RequireJSProcessor from piecrust.processing.sitemap import SitemapProcessor from piecrust.sources.base import DefaultPageSource -from piecrust.sources.posts import (FlatPostsSource, ShallowPostsSource, - HierarchyPostsSource) +from piecrust.sources.posts import ( + FlatPostsSource, ShallowPostsSource, HierarchyPostsSource) from piecrust.sources.autoconfig import AutoConfigSource from piecrust.sources.prose import ProseSource from piecrust.templating.jinjaengine import JinjaTemplateEngine @@ -42,6 +45,7 @@ ShowConfigCommand(), FindCommand(), PrepareCommand(), + ShowSourcesCommand(), ShowRoutesCommand(), ShowPathsCommand(), BakeCommand(),