summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-01-29 22:46:23 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-01-29 22:46:23 +0100
commitc709c2eb5ebb3a661d228423860f3bdd46dac375 (patch)
treeae34fccff93f00031a825097cda1edabc894e832
parentcf5270ab70e0753c3fa2c016233963f287253794 (diff)
Add option to show all search results
-rw-r--r--lesana/command.py47
1 files changed, 29 insertions, 18 deletions
diff --git a/lesana/command.py b/lesana/command.py
index dd1864a..56c855a 100644
--- a/lesana/command.py
+++ b/lesana/command.py
@@ -139,27 +139,35 @@ class Index(guacamole.Command):
class Search(guacamole.Command):
arguments = [
- (['--collection', '-c'], dict(
+ ]
+
+ def register_arguments(self, parser):
+ parser.add_argument(
+ '--collection', '-c',
help='The collection to work on (default .)'
- )),
- (['--template', '-t'], dict(
+ )
+ parser.add_argument(
+ '--template', '-t',
help='Am',
- )),
- (['--offset'], dict(
+ ),
+ parser.add_argument(
+ '--offset',
type=int,
- )),
- (['--pagesize'], dict(
+ ),
+ parser.add_argument(
+ '--pagesize',
type=int,
- )),
- (['query'], dict(
+ ),
+ parser.add_argument(
+ '--all',
+ action='store_true',
+ help='Return all available results'
+ )
+ parser.add_argument(
+ 'query',
help='Xapian query to search in the collection',
nargs='+'
- )),
- ]
-
- def register_arguments(self, parser):
- for arg in self.arguments:
- parser.add_argument(*arg[0], **arg[1])
+ ),
def invoked(self, ctx):
# TODO: implement "searching" for everything
@@ -177,9 +185,12 @@ class Search(guacamole.Command):
pagesize = ctx.args.pagesize or 12
collection = Collection(ctx.args.collection)
collection.start_search(' '.join(ctx.args.query))
- results = collection.get_search_results(
- offset,
- pagesize)
+ if ctx.args.all:
+ results = collection.get_all_search_results()
+ else:
+ results = collection.get_search_results(
+ offset,
+ pagesize)
if ctx.args.template:
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(