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

Fix(cli): Parse options insensitive to style #84

Merged

Conversation

ee7
Copy link
Member

@ee7 ee7 commented Oct 26, 2020

Most importantly, these previously invalid options are now accepted:

    --probspecsdir
    --prob-specs-dir
    --prob_specs_dir

Before this PR, we could only use:

    --probSpecsDir

That is: --kebab-case is now supported, even if that fact or --prob-specs-dir itself aren't shown in the --help message yet.

Note that we already had case-insensitive parsing for:

  • the values for mode
  • the values for verbosity
  • arguments (we support canonical_data_syncer HELP)

Fixes: #79

Most importantly, these previously invalid options are now accepted:
    --probspecsdir
    --prob-specs-dir
    --prob_specs_dir
Before this commit, we could only use:
    --probSpecsDir

That is: `--kebab-case` is now supported, even if that fact or
`--prob-specs-dir` itself aren't shown in the `--help` message yet.

Note that we already had case-insensitive parsing for:
  - the values for `mode`
  - the values for `verbosity`
  - arguments (we support `canonical_data_syncer HELP`)

Fixes: exercism#79
@ee7 ee7 requested a review from ErikSchierboom as a code owner October 26, 2020 12:45
@ee7
Copy link
Member Author

ee7 commented Oct 26, 2020

Changing the help message's --probSpecsDir to --prob-specs-dir needs to wait for a later PR, after some refactoring.

It'll make more sense later, but I'm deliberately using .toLowerAscii instead of changing the string value of the probSpecsDir enum to "prob-specs-dir" or "probspecsdir". It's better that it doesn't contain hyphens, and by keeping it camelCase I can reduce duplication and generate the help text in a later PR by using a camelCase -> kebab-case proc.

@ee7 ee7 mentioned this pull request Oct 26, 2020
3 tasks
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.

As a side note: it would be great to have unit tests to verify this.

src/cli.nim Show resolved Hide resolved
@ErikSchierboom ErikSchierboom merged commit 59dca7a into exercism:master Oct 27, 2020
@ee7 ee7 deleted the fix-cli-parse-options-insensitive-to-style branch October 27, 2020 14:04
ee7 added a commit to ee7/exercism-configlet that referenced this pull request Jan 21, 2021
Most importantly, these previously invalid options are now accepted:
    --probspecsdir
    --prob-specs-dir
    --prob_specs_dir
Before this commit, we could only use:
    --probSpecsDir

That is: `--kebab-case` is now supported, even if that fact or
`--prob-specs-dir` itself aren't shown in the `--help` message yet.

Note that we already had case-insensitive parsing for:
  - the values for `mode`
  - the values for `verbosity`
  - arguments (we support `canonical_data_syncer HELP`)

Fixes: exercism#79
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.

CLI: Parse options insensitive to case, '-' and '_'
2 participants