-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
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
Fix dashless option usage info #800
Fix dashless option usage info #800
Conversation
Aliases are prefixed with a dash if they do not contain one. However, this only makes sense on single letter aliases. Multi-character aliases with a single dash cannot actually be used (although they can be specified). Therefore, these tests are updated to use aliases that would actually work.
@@ -105,11 +105,11 @@ def option(name, options = {}) | |||
|
|||
describe "with key as an array" do | |||
it "sets the first items in the array to the name" do | |||
expect(parse([:foo, :bar, :baz], true).name).to eq("foo") | |||
expect(parse([:foo, :b, "--bar"], true).name).to eq("foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, these two tests were invalid.
Specifying a multicharacter alias without including leading dashes leads to a single dash being prepended (rather than two), which is invalid, as there is no way to invoke it.
By example:
Specified Alias | Final Alias |
---|---|
"-b" , :"-b" , "b" , :b , |
-b |
"--bar" , :"--bar" |
--bar |
"bar" , :bar |
-bar (invalid) |
Therefore, I updated these tests to use legitimate aliases, which then make sense with normalization.
Specifying invalid aliases is still allowed, it just now will generate a single dash in the usage documentation (which reflects what is actually going on).
Another PR could address forbidding invalid aliases (as they do not work, and would be misleading) in isolation.
Although specifying single letter aliases without a dash works, it generated incorrect USAGE documentation (the dash is missing). This moves the alias normalization to happen earlier, which ensures the aliases are described correctly in the USAGE documentation.
0e61aa3
to
ef1a323
Compare
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 (#6815) Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 (#6817) Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 (#6818) Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…) which started breaking the test. Till we find if recent release is stable and don't break any functionality we are pinning thor to < 1.3.0 (#6815) Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
🌈
When option aliases are specified without dashes
they are correctly handled when parsing the command
However the usage information does not include the dash. This PR fixes that by moving alias normalization to happen sooner, so it applies to both the usage information generator and the actual command: