Skip to content

Commit e57000d

Browse files
committed
Pass OptionParser to CLI.exe as option to allow for use in usage. This is necessary as command-specific options are added in the exe, so that option parser must be used when issuing help messages in order to see help on those options.
1 parent 756125d commit e57000d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

bin/rdf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ end
2626

2727
abort options.banner if ARGV.empty? && !options.options[:evaluate]
2828

29-
RDF::CLI.exec(ARGV, options.options)
29+
# Add option_parser to parsed options to enable help
30+
RDF::CLI.exec(ARGV, options.options.merge(option_parser: options))

lib/rdf/cli.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,16 @@ def self.exec(args, options = {})
345345
cmds, args = args.partition {|e| commands.include?(e.to_s)}
346346

347347
if cmds.empty?
348-
usage(options)
348+
usage(options.fetch(:option_parser, self.options))
349349
abort "No command given"
350350
end
351351

352352
if cmds.first == 'help'
353353
on_cmd = cmds[1]
354354
if on_cmd && COMMANDS.fetch(on_cmd.to_sym, {})[:help]
355-
usage(self.options, banner: "Usage: #{self.basename.split('/').last} #{COMMANDS[on_cmd.to_sym][:help]}")
355+
usage(options.fetch(:option_parser, self.options), banner: "Usage: #{self.basename.split('/').last} #{COMMANDS[on_cmd.to_sym][:help]}")
356356
else
357-
usage(self.options)
357+
usage(options.fetch(:option_parser, self.options))
358358
end
359359
return
360360
end

0 commit comments

Comments
 (0)