From 09724ca3f1eb1d0d726ba0f6288b44bdc073994e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 20 Sep 2013 07:01:33 +0000 Subject: dtas-tl: add "reto" command This behaves like "goto", but takes a regular expression instead of a track_id --- bin/dtas-tl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bin') diff --git a/bin/dtas-tl b/bin/dtas-tl index f34a83c..7793f23 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -47,6 +47,26 @@ when "addtail" puts "#{path} #{res}" last_id = res if res =~ /\A\d+\z/ end +when "reto" + fixed = ARGV.delete("-F") + ignorecase = ARGV.delete("-i") + re = ARGV[1] + time = ARGV[2] + re = Regexp.quote(re) if fixed + re = ignorecase ? %r{#{re}}i : %r{#{re}} + get_track_ids(c).each do |track_id| + res = c.req("tl get #{track_id}") + res.sub!(/\A1 /, '') + if re =~ res + req = %W(tl goto #{track_id}) + req << time if time + res = c.req(req) + puts res + exit(res == "OK") + end + end + warn "#{re.inspect} not found" + exit 1 else # act like dtas-ctl for now... puts c.req([ "tl", *ARGV ]) -- cgit v1.2.3-24-ge0c7