From 24f720801ece36ab13c6acc159b7cb0d05136840 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Wed, 21 Dec 2016 09:40:40 +0100 Subject: Add indexing command --- lesana/command.py | 16 +++++++++++++++- scripts/lesana | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lesana/command.py b/lesana/command.py index e6dbce8..e900aad 100644 --- a/lesana/command.py +++ b/lesana/command.py @@ -11,7 +11,21 @@ class New(gadona.Command): ] def main(self): - collection = Collection() + collection = Collection(self.settings.collection) new_entry = Entry(collection) collection.save_entries([new_entry]) print(new_entry.fname) + + +class Index(gadona.Command): + name = 'index' + arguments = [ + (['--collection', '-c'], dict( + help='The collection to work on (default .)' + )), + ] + + def main(self): + collection = Collection(self.settings.collection) + indexed = collection.update_cache() + print("Found and indexed {} entries".format(indexed)) diff --git a/scripts/lesana b/scripts/lesana index 0cc8a0e..3886f52 100755 --- a/scripts/lesana +++ b/scripts/lesana @@ -1,12 +1,13 @@ #!/usr/bin/env python3 import gadona -from lesana.command import New +from lesana.command import New, Index if __name__ == '__main__': app = gadona.App() app.description = "Manage collections" app.commands = [ New(), + Index(), ] app.main() -- cgit v1.2.3