From 564745e3f2a6fa427414009b8eec74b6ed06ed8f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Dec 2015 19:01:18 +0000 Subject: dtas-tl: add "aac" (add-after-current) command This can be useful to avoid using the queue internally. --- bin/dtas-tl | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'bin') 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") -- cgit v1.2.3-24-ge0c7