59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/bunch/cli.rb', line 59
def parse_opts
options = {:individual => true}
opts = OptionParser.new do |opts|
opts.banner = 'Usage: bunch [options] INPUT_PATH [OUTPUT_PATH]'
opts.on '-s', '--server', 'Instead of creating files, use WEBrick to serve files from INPUT_PATH.' do
options[:server] = true
end
opts.on '-i', '--[no-]individual', 'Create one output file for each file or directory in the input path (default).' do |i|
options[:individual] = i
end
opts.on '-a', '--all', 'Create an all.[extension] file combining all inputs.' do
options[:all] = true
end
opts.on '-r', '--recurse', 'Recursively generate one output file for every input file and directory.' do
options[:recurse] = true
end
opts.on_tail '-h', '--help', 'Show this message.' do
puts opts
exit
end
end
opts.parse!
if ARGV.count < 1
raise "Must give an input path.\n\n#{opts}"
end
if ARGV.count < 2 && options[:individual] && !options[:server]
raise "Must give an output path unless --no-individual or --server is provided."
end
input = ARGV.shift
output = ARGV.shift
[input, output, options]
end
|