about summary refs log tree commit homepage
path: root/bin/dtas-mlib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-11-28 11:09:27 +0000
committerEric Wong <e@80x24.org>2015-11-28 11:09:56 +0000
commit2d444cadc7c5dc42d89c02a9d999938c40bdcb9d (patch)
tree4bd51f78f69141b2a7132526edd60f0ffa229e47 /bin/dtas-mlib
parent9581a01c87a7d8bf228bdec7d4f06bf8a3fed3ec (diff)
downloaddtas-2d444cadc7c5dc42d89c02a9d999938c40bdcb9d.tar.gz
Using an RFC-822-like format since YAML quoting rules aren't very
human-friendly, and we already prevent newlines from entering our
DB anyways.
Diffstat (limited to 'bin/dtas-mlib')
-rwxr-xr-xbin/dtas-mlib18
1 files changed, 12 insertions, 6 deletions
diff --git a/bin/dtas-mlib b/bin/dtas-mlib
index 0e17d91..6331808 100755
--- a/bin/dtas-mlib
+++ b/bin/dtas-mlib
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 # Copyright (C) 2015 all contributors <dtas-all@nongnu.org>
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-usage = "#$0 [-d DATABASE-URI] ACTION [DIRECTORY]"
+usage = "#$0 [-d DATABASE-URI] ACTION [ARGS]"
 Thread.abort_on_exception = $stderr.sync = $stdout.sync = true
 require 'dtas/mlib'
 require 'optparse'
@@ -27,13 +27,19 @@ unless db.include?('://')
   end
 end
 
+def mlib(db, migrate: false)
+  m = DTAS::Mlib.new(db)
+  m.migrate if migrate
+  m
+end
+
 case action = ARGV.shift
-when 'update'
+when 'update', 'up'
   directory = ARGV.shift or abort "DIRECTORY required\n#{usage}"
+  mlib(db, migrate: true).update(directory)
+when 'dump' # mainly for debugging
+  directory = ARGV.shift || '/'
+  mlib(db).dump(directory)
 else
   abort usage
 end
-
-mlib = DTAS::Mlib.new(db)
-mlib.migrate
-mlib.__send__(action, directory)