Skip to content

Allow boolean flags without automatically creating a --no-option version #553

Closed
@whopper

Description

@whopper

Context: I'm working on a command that needs a boolean flag, we'll call it --list. If this flag is provided, I want to display a list of items. Otherwise, the list will not be displayed. Currently, if I add this option like so:

method_option :list, type: :boolean

Thor automatically creates a --no-list option, which I don't need and is confusing in the help output:

Options:
  [--list], [--no-list]

This is due to this line: https://github.com/erikhuda/thor/blob/db16e19ad4bc797c580a2646ab54606fd0fd294f/lib/thor/parser/option.rb#L91

Thor should be able to create a boolean flag like this with a default value (false in this case) and not create the negation of the option.

Alternatively, perhaps this is just bad style? Should I be implementing list as a subcommand? Any thoughts are appreciated!

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