-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement switch -h, --help to CLI #238
base: master
Are you sure you want to change the base?
Conversation
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.
Tests? 🤔
thanks for reminding 😮💨 |
02713e6
to
05c7649
Compare
05c7649
to
79dad90
Compare
…o add new ones in future
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.
I think I found an error. If a value is provided for the -h
switch, MatchError
is raised.
$ ./onigumo -h value
** (MatchError) no match of right hand side value: :error
(onigumo 0.1.0) lib/cli.ex:16: Onigumo.CLI.main/1
(elixir 1.17.2) lib/kernel/cli.ex:136: anonymous fn/3 in Kernel.CLI.exec_fun/2
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.
Update: the error I found is not a problem of this pull request. Its happens when an invalid component (a positional argument) is passed. It is a known issue #179.
…these combinations
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.
Unfortunately, a combination of -h
/--help
and a positional argument doesn’t work as expected. See my inline comment.
lib/cli.ex
Outdated
@@ -30,6 +33,7 @@ defmodule Onigumo.CLI do | |||
COMPONENT\tOnigumo component to run, available: #{components} | |||
|
|||
OPTIONS: | |||
-h, --help\t\tprint this help |
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.
Capitalized, this sentence would be more consistent.
-h, --help\t\tprint this help | |
-h, --help\t\tPrint this help |
@@ -39,6 +44,12 @@ defmodule OnigumoCLITest do | |||
end | |||
end | |||
|
|||
for switches <- @invalid_switch_combinations do |
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.
There is one more user story of providing both a positional argument and the help switch. If ran in the ./onigumo downloader -h
order, the -h
switch is ignored.
This case is not tested and because it doesn’t work correctly, the test would fail. The expected result is a help message to be printed because of an invalid argument combination. The actual result is that the downloader is run.
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.
that should be already tested but it is strange that github does not mark as as outdated. I suppose it because the line of code you mark is not changed but in text is mentioned case of test which is not added in your changes.
My observation of The question is whether to add a test case for the combination of the help switch and the component. Because of the existing bug, the test would fail and essentially make this pull request blocked. We can keep this test for the fix and by that let this pull request go through. |
In my previous comment, I was wrong! 😮 It’s only the
|
To make it clearer:
|
I found the reason, why the behavior changed:
This pull request then does introduce the bug in the sense that in didn’t exist because there was no help option. At the same time, it only reveals an existing issue of unscalable pattern matching of the This can be still resolved tactically by using my code suggestion still being purely based on pattern-matching, probably in a separate pull request unblocking this one. The strategic solution is however to replace the pattern matching by something scalable. |
|
Fix #205