Sha256: 9a3db1de6f6153917b04691fda91ab64440f2524e6b970fc5b9a0ea32fb19e7e

Contents?: true

Size: 799 Bytes

Versions: 9

Compression:

Stored size: 799 Bytes

Contents

require 'pp'
class RakeCommander::Custom::ChainedPlus < RakeCommander::Custom::Chained
  desc 'A task+ you want to chain to'
  task :chained_plus

  option_remove :say
  option :e, '--exit-on-error', TrueClass, desc: 'If it should just exit on "missing argument" error or raise an exception'
  # Move option to the end, make **required** the argument (SOMETHING) as well as the option itself.
  option :s, '--say SOMETHING', "It says 'something'", required: true

  error_on_options error: RakeCommander::Options::Error::MissingArgument do |err, _argv, results, _leftovers|
    msg  = "Parsed results when 'missing argument' error was raised"
    msg << "\non option '#{err.option.name_full}'" if err.option
    puts "#{msg} => #{results.pretty_inspect}"
    !results[:e]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rake-commander-0.2.11 examples/03_b_chained_plus_example.rb
rake-commander-0.2.10 examples/03_b_chained_plus_example.rb
rake-commander-0.2.7 examples/03_b_chained_plus_example.rb
rake-commander-0.2.6 examples/03_b_chained_plus_example.rb
rake-commander-0.2.5 examples/03_b_chained_plus_example.rb
rake-commander-0.2.4 examples/03_b_chained_plus_example.rb
rake-commander-0.2.3 examples/03_b_chained_plus_example.rb
rake-commander-0.2.2 examples/03_b_chained_plus_example.rb
rake-commander-0.2.0 examples/03_b_chained_plus_example.rb