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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/spfy/optionreader.rb', line 3
def self.parse(args)
options = OpenStruct.new
options.output = []
options.verbose = false
options.hide_title = false
options.hide_artist = false
options.hide_album = false
options.hide_tracknum = false
opts = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [options] [source]"
opts.separator ""
opts.separator "Output:"
opts.on("-o", "--output FILE", "File to output XSPF data to") do |out|
options.output << out
end
opts.on("-t", "--no-title", "Suppress track title in output") do
options.hide_title = true
end
opts.on("-a", "--no-artist", "Suppress artist name in output") do
options.hide_artist = true
end
opts.on("-l", "--no-album", "Suppress album name in output") do
options.hide_album = true
end
opts.on("-n", "--no-tracknum", "Suppress track number in output") do
options.hide_tracknum = true
end
opts.separator ""
opts.separator "Common options:"
opts.on("-v", "--version", "Display version information") do
puts "#{File.basename($0).capitalize} #{$version} Copyright (c) 2012 Marc Ransome <[email protected]>"
puts "This program comes with ABSOLUTELY NO WARRANTY, use it at your own risk."
puts "This is free software, and you are welcome to redistribute it under"
puts "certain conditions; type `#{File.basename($0)} --license' for details."
exit
end
opts.on_tail("-h", "--help", "Show this screen") do
puts opts
exit
end
end
opts.parse!(args)
args.each do |dir|
if File.directory?(dir)
$dirs << dir
end
end
options
end
|