about summary refs log tree commit homepage
path: root/bin/dtas-tl
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-15 19:01:18 +0000
committerEric Wong <e@80x24.org>2015-12-15 19:02:25 +0000
commit564745e3f2a6fa427414009b8eec74b6ed06ed8f (patch)
tree93fecda1b6d092e25a476a7324fbff369afdcffa /bin/dtas-tl
parent0ff9143addb12f113d42f507e976f0ea83288fe7 (diff)
downloaddtas-564745e3f2a6fa427414009b8eec74b6ed06ed8f.tar.gz
This can be useful to avoid using the queue internally.
Diffstat (limited to 'bin/dtas-tl')
-rwxr-xr-xbin/dtas-tl25
1 files changed, 17 insertions, 8 deletions
diff --git a/bin/dtas-tl b/bin/dtas-tl
index 76efb8f..f48c6ef 100755
--- a/bin/dtas-tl
+++ b/bin/dtas-tl
@@ -99,6 +99,17 @@ ensure
   tmp.close! if tmp
 end
 
+def add_after(c, argv, last_id)
+  argv.each do |path|
+    path = File.expand_path(path)
+    req = %W(tl add #{path})
+    req << last_id.to_s if last_id
+    res = c.req(req)
+    print "#{path} #{res}\n"
+    last_id = res if res =~ /\A\d+\z/
+  end
+end
+
 c = DTAS::UNIXClient.new
 case cmd = ARGV[0]
 when "cat"
@@ -107,6 +118,11 @@ when "cat"
     res.sub!(/\A1 /, '')
     print "#{res}\n"
   end
+when 'aac' # add-after-current
+  ARGV.shift
+  rv = c.req(%w(tl current-id))
+  last_id = rv =~ %r{\A\d+\z} ? rv.to_i : nil
+  add_after(c, ARGV, last_id)
 when "addhead"
   ARGV.shift
   ARGV.reverse_each do |path|
@@ -118,14 +134,7 @@ when "addtail"
   ARGV.shift
   track_ids = get_track_ids(c)
   last_id = track_ids.pop
-  ARGV.each do |path|
-    path = File.expand_path(path)
-    req = %W(tl add #{path})
-    req << last_id.to_s if last_id
-    res = c.req(req)
-    print "#{path} #{res}\n"
-    last_id = res if res =~ /\A\d+\z/
-  end
+  add_after(c, ARGV, last_id)
 when "reto"
   fixed = ARGV.delete("-F")
   ignorecase = ARGV.delete("-i")