Skip to content

Allow suppression of auto-created 'no-' flags for boolean options #417

Description

@mbrgm

The name of my option is --all. But I do not want the usage instructions to include a --no-all flag, as this is already the default behaviour.

https://github.com/erikhuda/thor/blob/d634d240bdc0462fe677031e1dc6ed656e54f27e/lib/thor/parser/option.rb#L89 already excludes the automatically inverted flag when the option name is 'force'. Maybe one could simply turn this into a metadata option (and include 'force' in some kind of blacklist for auto-inversed options).

Feature: Automatically created '--no-' options can be suppressed
  As a developer
  I want to be able to suppress the automatically created '--no-' flag for boolean options
  In order to remove them from the usage description

  Scenario: Automatically created '--no-' flag is suppressed explicitely
    When I create an option `:foo`
    And I set the option's `:type` to `:boolean`
    And I supply a metadata key `:auto_inversion` with a value of `false`
    Then the usage instructions of the command should not include a '--no-foo' flag

  Scenario: Automatically created '--no-' flag is requested explicitely
    When I create an option `:foo`
    And I set the option's `:type` to `:boolean`
    And I supply a metadata key `:auto_inversion` with a value of `true`
    Then the usage instructions of the command should include a '--no-foo' flag

  Scenario: Automatically created '--no-' flag is created by default
    When I create an option `:foo`
    And I set the option's `:type` to `:boolean`
    Then the usage instructions of the command should include a '--no-foo' flag

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions