# HG changeset patch # User Ludovic Chabant # Date 1420176846 28800 # Node ID 4534ccbdd2a3e1fe2184d720fbf1bdc82dc06a6a # Parent 6d23473fab415de41537527a1eba56c5ea4327e9 find: Fix the `find` command, add more options. The `--endpoint` option doesn't make any sense anymore since page sources could have non-file-system endpoints. This was replaced with `--name` to match source names instead. Also added `--include-theme`, with filtering out theme pages by default, and `--exact` to explicitely match the given pattern, with matching anything that contains the pattern by default. diff -r 6d23473fab41 -r 4534ccbdd2a3 piecrust/commands/builtin/info.py --- a/piecrust/commands/builtin/info.py Thu Jan 01 21:21:00 2015 -0800 +++ b/piecrust/commands/builtin/info.py Thu Jan 01 21:34:06 2015 -0800 @@ -112,12 +112,11 @@ def setupParser(self, parser, app): parser.add_argument( 'pattern', - help="The pattern to match with page slugs", + help="The pattern to match with page filenames", nargs='?') parser.add_argument( - '--endpoint', - help="The endpoint(s) to look into", - nargs='+') + '-n', '--name', + help="Limit the search to sources matching this name") parser.add_argument( '--full-path', help="Return full paths instead of root-relative paths", @@ -126,14 +125,28 @@ '--metadata', help="Return metadata about the page instead of just the path", action='store_true') + parser.add_argument( + '--include-theme', + help="Include theme pages to the search", + action='store_true') + parser.add_argument( + '--exact', + help=("Match the exact given pattern, instead of any page " + "containing the pattern"), + action='store_true') def run(self, ctx): pattern = ctx.args.pattern sources = list(ctx.app.sources) - if ctx.args.endpoint: - endpoints = ctx.args.endpoint - sources = [s for s in sources if s.endpoint in endpoints] + if not ctx.args.exact: + pattern = '*%s*' % pattern + for src in sources: + if not ctx.args.include_theme and src.is_theme_source: + continue + if ctx.args.name and not fnmatch.fnmatch(src.name, ctx.args.name): + continue + page_facs = src.getPageFactories() for pf in page_facs: name = os.path.relpath(pf.path, ctx.app.root_dir)