You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dry-cli allows one to define duplicate options that override each other. However, the all show up when running --help.
While in a single class this is easy to avoid, when building many commands and sharing behavior, it's easy to accidentally include extra options. See: hanami/cli#278
To Reproduce
In test.rb:
require "dry/cli"
module Foo
module CLI
module Commands
extend Dry::CLI::Registry
class Request < Dry::CLI::Command
option :mode, default: "http", values: %w[http http2]
option :mode, default: "foo", values: %w[bar baz]
def call(**options) = puts "Performing a request (mode: #{options.fetch(:mode)})"
end
register "request", Request
end
end
end
Dry::CLI.new(Foo::CLI::Commands).call
It shows both --modes. Same thing happens if they're identical, too.
Expected behavior
I would expect either:
The second option to override the first one and completely remove the first one from --help (since this is what actually happens when you try to execute it with that option. only bar/baz are valid, not http/http2.
An error to be raised, saying it's not allowed
My environment
Ruby 3.3, dry-cli 1.2.0 (latest as of writing this)
The text was updated successfully, but these errors were encountered:
Describe the bug
dry-cli allows one to define duplicate options that override each other. However, the all show up when running
--help
.While in a single class this is easy to avoid, when building many commands and sharing behavior, it's easy to accidentally include extra options. See: hanami/cli#278
To Reproduce
In
test.rb
:Then
It shows both
--mode
s. Same thing happens if they're identical, too.Expected behavior
I would expect either:
--help
(since this is what actually happens when you try to execute it with that option. only bar/baz are valid, not http/http2.My environment
Ruby 3.3, dry-cli 1.2.0 (latest as of writing this)
The text was updated successfully, but these errors were encountered: