svenfuchs/cl

View on GitHub
examples/readme/negate

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
$: << File.expand_path('lib')

require 'cl'

class Add < Cl::Cmd
  register :add

  opt '--notifications', 'Send out notifications to the team', negate: %w(skip)

  def run
    p notifications?
  end
end

Cl.new('owners').run(%w(add --notifications))

# Output:
#
#   true

Cl.new('owners').run(%w(add --no_notifications))

# Output:
#
#   false

Cl.new('owners').run(%w(add --no-notifications))

# Output:
#
#   false

Cl.new('owners').run(%w(add --skip_notifications))

# Output:
#
#   false

Cl.new('owners').run(%w(add --skip-notifications))

# Output:
#
#   false