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

commandline: Refactor and streamline special syntaxes #2264

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

Geod24
Copy link
Member

@Geod24 Geod24 commented Jun 10, 2022

All those special syntaxes only trigger if args.length >= 2,
so first we can nest them in a new scope, which also makes
it visually more distinct.
Additionally, the third and second cases were actually inverted:
if the third case was to pass, it means the second case couldn't
have passed (because they check present/absence of an extension,
respectively), so we can swap them and use an else-if.
The result is arguably much more readable.

@Geod24 Geod24 force-pushed the minor-refactor branch 2 times, most recently from c9a9e05 to 05e4d41 Compare June 10, 2022 13:47
All those special syntaxes only trigger if args.length >= 2,
so first we can nest them in a new scope, which also makes
it visually more distinct.

Additionally, the third and second cases were actually inverted:
if the third case was to pass, it means the second case couldn't
have passed (because they check present/absence of an extension,
respectively), so we can swap them and use an else-if.

The result is arguably much more readable, and highlight the fact
that if the first case (stdin) is used, the second case will.
@Geod24
Copy link
Member Author

Geod24 commented Jun 13, 2022

So all the cases were actually dependent on each other. I hope the new code is clearer.

@Geod24 Geod24 merged commit deea6c2 into dlang:master Jun 13, 2022
@Geod24 Geod24 deleted the minor-refactor branch June 13, 2022 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants