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
|
# File 'lib/ppcommand/cli.rb', line 10
def self.execute(argv)
opts = {:type => "auto"}
opp = OptionParser.new
opp.banner = "pp [options] [file|URI]"
opp.on_tail("-h", "--help", "show this help.") do
puts opp
exit
end
opp.on_tail("-v", "--version", "show version.") do
puts "ppcommand #{ PPCommand::VERSION }"
exit
end
opp.on("-c", "--csv", "parse CSV and pp."){|x| opts[:type] = "csv"}
opp.on("-C", "--csvtable", "parse CSV, add labels and pp."){|x| opts[:type] = "csvtable"}
opp.on("-H", "--html", "parse HTML and pp."){|x| opts[:type] = "html"}
opp.on("-j", "--json", "parse JSON and pp."){|x| opts[:type] = "json"}
opp.on("-x", "--xml", "parse XML using REXML and pp."){|x| opts[:type] = "xml"}
opp.on("-X", "--xmlsimple", "parse XML using XMLSimple and pp."){|x| opts[:type] = "xmlsimple"}
opp.on("-y", "--yaml", "parse YAML and pp."){|x| opts[:type] = "yaml"}
opp.on("-Y", "--syck", "parse YAML using Syck and pp."){|x| opts[:type] = 'syck'}
opp.on("-t", "--text", "do not parse. print plain text."){|x| opts[:type] = "text"}
opp.parse!(argv)
file = argv.shift
PPCommand::Main.new.execute(opts, file)
end
|