Skip to content
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

Replace case with with #245

Closed
wants to merge 3 commits into from
Closed

Replace case with with #245

wants to merge 3 commits into from

Conversation

Glutexo
Copy link
Owner

@Glutexo Glutexo commented Nov 9, 2024

The case statement is too complex for situations when we want to focus on the success branch. This is the case of OptionParser.parse, which fails on invalid input, but requires complex parsing of correct switches and arguments.

The case statement is too complex for situations when we want to focus
on the success branch. This is the case of OptionParser.parse, which
fails on invalid input, but requires complex parsing of correct
switches and arguments.
@Glutexo Glutexo added the cli label Nov 9, 2024
@Glutexo Glutexo self-assigned this Nov 9, 2024
@Glutexo Glutexo requested a review from nappex November 9, 2024 18:19
lib/cli.ex Outdated
{:ok, module} = Map.fetch(@components, String.to_atom(component))
working_dir = Keyword.get(parsed_switches, :working_dir, File.cwd!())
module.main(working_dir)
parse_result =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse should be enough, but at least parsed_result with d is more semantically right in my opinion.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 parsed_result doesn’t seem right to me: it’s not a result that has been parsed; it’s a result of parsing. parse_result tried to convey the message that it’s a result of the parse function.

Shortened to a single word, parsed may be a better choice. parse sounds like an action rather than a value.

lib/cli.ex Outdated

_ ->
usage_message()
with {parsed_switches, [component], []} <- parse_result do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There you can see that you call parsed_switches as parsed_switches but the result is not parsed only parse, it is not consistent.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse_result is a result of a parse function. parsed_switches on the other hand are really switches that have been parsed. The “result” has not been parsed – the args were and the “result” is the result of that.

I don’t really like the parsed_switches name. But since it’s there, I think the most consistent option for parse_result would be just parsed or parsed_argv.

For consistency with the parsed_switches variable.
@Glutexo Glutexo requested a review from nappex November 9, 2024 18:35
@nappex
Copy link
Collaborator

nappex commented Dec 17, 2024

case was replaced by #250

@nappex nappex closed this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants