We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm looking to define options with arguments that can take a command to run in a process. Something like this
my-cli 'rake TEST=<test>'
arguments using = character aren't parsed as arguments and get set to nil.
=
nil
require "bundler/inline" gemfile do source "https://rubygems.org" gem "tty-option" gem "minitest" end require "tty-option" require "minitest/autorun" class MyOptions include TTY::Option argument :command end class TestHardcodedString < Minitest::Test def test_special_characters_as_arguments options = MyOptions.new options.parse(["rake TEST=<test>"]) # ASSERTION FAILS assert_equal "rake TEST=<test>", options.params[:command] end def test_reference_without_equal_sign options = MyOptions.new options.parse(["rake test <test>"]) # ASSERTION PASSES assert_equal "rake test <test>", options.params[:command] end end
Result
# Running: .F Finished in 0.001068s, 1872.6592 runs/s, 1872.6592 assertions/s. 1) Failure: TestHardcodedString#test_special_characters_as_arguments [tty-option-hardcoded-string-for-command.rb:25]: Expected: "rake TEST=<test>" Actual: nil 2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
Actual behaviour options.params[:command] => nil
options.params[:command] => nil
Expected behaviour options.params[:command] => 'rake TEST=<test>'
options.params[:command] => 'rake TEST=<test>'
It currently happens because the regex for arguments prevents the use of = and - characters https://github.com/piotrmurach/tty-option/blob/master/lib/tty/option/parser/param_types.rb#L8
-
While the pull request #13 is not the right fix it does show tests that illustrate why the regex does not parse and = and - characters
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the problem
I'm looking to define options with arguments that can take a command to run in a process. Something like this
my-cli 'rake TEST=<test>'
arguments using
=
character aren't parsed as arguments and get set tonil
.Steps to reproduce the problem
Result
Actual behaviour
options.params[:command] => nil
Expected behaviour
options.params[:command] => 'rake TEST=<test>'
Context
It currently happens because the regex for arguments prevents the use of
=
and-
charactershttps://github.com/piotrmurach/tty-option/blob/master/lib/tty/option/parser/param_types.rb#L8
While the pull request #13 is not the right fix it does show tests that illustrate why the regex does not parse and = and - characters
Describe your environment
The text was updated successfully, but these errors were encountered: