From e6ca961fd5fe69afeec6c024dfbf9f12a3decde1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 7 Jan 2022 05:35:41 +0000 Subject: archive: support comments, default to none The default "Processed by SoX" comment is pointless, and I often want to archive + tag something in one step to reduce FS I/O. --- bin/dtas-archive | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/dtas-archive b/bin/dtas-archive index dd3b537..c88873e 100755 --- a/bin/dtas-archive +++ b/bin/dtas-archive @@ -29,6 +29,7 @@ repeat = 1 stats = false keep_going = false compression = [] +comment = [] OptionParser.new('', 24, ' ') do |op| op.banner = usage @@ -36,6 +37,7 @@ OptionParser.new('', 24, ' ') do |op| op.on('-C', '--compression [FACTOR]', 'compression factor for sox') { |c| compression = [ '-C', c ] } + op.on('--comment=TEXT', String) { |c| comment.push('--comment', c) } op.on('-j', '--jobs [JOBS]', Integer) { |j| jobs = j } op.on('-S', '--stats', 'save stats on the file') { stats = true } op.on('-k', '--keep-going', 'continue after error') { keep_going = true } @@ -53,6 +55,8 @@ OptionParser.new('', 24, ' ') do |op| op.parse!(ARGV) end +comment.push('--comment', '') if comment.empty? + dst = ARGV.pop src = ARGV.dup @@ -137,7 +141,7 @@ thrs = jobs.times.map do |i| if dry_run || !silent names = job.map { |x| Shellwords.escape(x) } - cmd = [ 'sox', *names ] + cmd = [ 'sox', names[0], *compression, *comment, names[1] ] if stats cmd << 'stats' cmd << "2>#{Shellwords.escape(stats_out)}" @@ -151,7 +155,7 @@ thrs = jobs.times.map do |i| end end - cmd = [ 'sox', input, *compression, output ] + cmd = [ 'sox', input, *compression, *comment, output ] if stats cmd << 'stats' cmd = [ *cmd, { err: stats_out } ] -- cgit v1.2.3-24-ge0c7