diff options
author | Eric Wong <e@80x24.org> | 2015-12-14 04:48:01 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-12-14 04:48:01 +0000 |
commit | 0dde5917fb5135ee3601383c29ffc0490071ea9d (patch) | |
tree | 4e2b4f2cb9e42ffbbda3f0b6c0f6d0c96c3cafb6 /bin | |
parent | 459519080c929211f5cf2997c22d1155c7fd1383 (diff) | |
download | dtas-0dde5917fb5135ee3601383c29ffc0490071ea9d.tar.gz |
No need to keep track of added track IDs when we can walk the array backwards to insert in the correct order. Also, fix a stupid (probably?) typo in the "addhead" implementation, too. I've known about Array#reverse_each for a while...
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/dtas-tl | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/bin/dtas-tl b/bin/dtas-tl index b682e2b..e375ff2 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -105,7 +105,7 @@ when "cat" end when "addhead" ARGV.shift - ARGV.reverse.each do |path| + ARGV.reverse_each do |path| path = File.expand_path(path) res = c.req(%W(tl add #{path})) print "#{path} #{res}\n" @@ -114,13 +114,11 @@ when "addtail" ARGV.shift track_ids = get_track_ids(c) last_id = track_ids.pop - ARGV.each do |path| + ARGV.reverse_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 when "reto" fixed = ARGV.delete("-F") |