@@ -3,28 +3,24 @@ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
3
3
require 'rubygems'
4
4
require 'rdf/cli'
5
5
6
- options = RDF ::CLI . options do
7
- self . on ( '-v' , '--verbose' , 'Enable verbose output. May be given more than once.' ) do
8
- self . options [ :logger ] . level = Logger ::INFO
9
- end
6
+ options = RDF ::CLI . options ( ARGV )
10
7
11
- self . on ( '-V' , '--version' , 'Display the RDF.rb version and exit.' ) do
12
- puts RDF ::VERSION ; exit
13
- end
8
+ abort options . banner if ARGV . empty? && !options . options [ :evaluate ]
9
+
10
+ # Add option_parser to parsed options to enable help
11
+ begin
12
+ messages = { }
13
+ RDF ::CLI . exec ( options . args , option_parser : options , **options . options . merge ( messages : messages ) )
14
14
15
- ARGV . select { |a | RDF ::CLI . commands . include? ( a ) } . each do |cmd |
16
- # Load command-specific options
17
- Array ( RDF ::CLI ::COMMANDS [ cmd . to_sym ] [ :options ] ) . each do |cli_opt |
18
- on_args = cli_opt . on || [ ]
19
- on_args << cli_opt . description if cli_opt . description
20
- self . on ( *on_args ) do |arg |
21
- self . options [ cli_opt . symbol ] = cli_opt . call ( arg )
15
+ unless messages . empty?
16
+ $stdout. puts "Messages:"
17
+ messages . each do |kind , term_messages |
18
+ term_messages . each do |term , messages |
19
+ $stdout. puts "#{ kind } #{ term } "
20
+ messages . each { |m | $stdout. puts " #{ m } " }
22
21
end
23
22
end
24
23
end
24
+ rescue ArgumentError => e
25
+ RDF ::CLI . abort e . message
25
26
end
26
-
27
- abort options . banner if ARGV . empty? && !options . options [ :evaluate ]
28
-
29
- # Add option_parser to parsed options to enable help
30
- RDF ::CLI . exec ( ARGV , options . options . merge ( option_parser : options ) )
0 commit comments