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

Refactor(cli): Reduce duplication #86

Merged
merged 6 commits into from
Oct 27, 2020

Conversation

ee7
Copy link
Member

@ee7 ee7 commented Oct 26, 2020

To-do

This PR reduces the code duplication in cli.nim.

The commits are atomic - please review individually. But they can be squashed before merging, if we prefer, given that they work towards the same goal.

Motivations:

  • We don't need separate parseMode and parseVerbosity functions -
    we can just have a generic parseValue proc, which is easily
    extended if we ever add more options that have values.
  • There should be a single source of truth for the string values of
    options/values.
  • This refactoring makes it easier to add support for unambiguous
    abbreviations of options.
  • We don't need to specify all the short options, just the short options
    that we don't want to have.

@ErikSchierboom
Copy link
Member

@ee7 Let me know when you want this to be reviewed.

@ee7 ee7 force-pushed the refactor-cli-DRY branch from d098090 to 5dd0b64 Compare October 27, 2020 14:09
@ee7 ee7 marked this pull request as ready for review October 27, 2020 14:10
@ee7 ee7 requested a review from ErikSchierboom as a code owner October 27, 2020 14:10
Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

Very nice addition! Makes adding new options a lot easier. I do wish we had some unit tests to verify the behavior :)

@ErikSchierboom ErikSchierboom merged commit 0b7a848 into exercism:master Oct 27, 2020
@ee7 ee7 deleted the refactor-cli-DRY branch October 27, 2020 14:28
ee7 added a commit to ee7/exercism-configlet that referenced this pull request Jan 21, 2021
Refactor(cli): Reduce duplication

Motivations:
- We don't need separate `parseMode` and `parseVerbosity` functions -
  we can just have a generic `parseValue` proc, which is easily
  extended if we ever add more options that have values.
- There should be a single source of truth for the string values of
  options/values.
- This refactoring makes it easier to add support for unambiguous
  abbreviations of options.
- We don't need to specify all the short options, just the short options
  that we don't want to have.
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