summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2016-12-21 09:40:40 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2016-12-21 09:40:40 +0100
commit24f720801ece36ab13c6acc159b7cb0d05136840 (patch)
tree61db07abde4c2c285a0c1518cedb9b570a2f3f5b
parentbb97d461aa1c229152b337d466fb2089ef1861ef (diff)
Add indexing command
-rw-r--r--lesana/command.py16
-rwxr-xr-xscripts/lesana3
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()