1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/env ruby
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require 'yaml'
require 'optparse'
require 'dtas/splitfx'
usage = "#$0 [-n|--dry-run][-j [JOBS]] SPLITFX_FILE.yml [TARGET]"
overrides = {} # FIXME: not tested
dryrun = false
jobs = 1
op = OptionParser.new('', 24, ' ') do |opts|
opts.banner = usage
opts.on('-n', '--dry-run') { dryrun = true }
opts.on('-j', '--jobs [JOBS]', Integer) { |val| jobs = val }
opts.parse!(ARGV)
end
args = []
ARGV.each do |arg|
case arg
when %r{\A(\w+)=(.*)\z}
key, val = $1, $2
# only one that makes sense is infile=another_file
overrides[key] = YAML.load(val)
when %r{\A(\w+)\.(\w+)=(.*)\z}
# comments.ARTIST='blah'
top, key, val = $1, $2, $3
hsh = overrides[top] ||= {}
hsh[key] = val
else
args << arg
end
end
file = args.shift or abort usage
target = args.shift || "flac"
splitfx = DTAS::SplitFX.new
splitfx.import(YAML.load(File.read(file)), overrides)
splitfx.run(target, jobs, dryrun)
|