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

enhancements to permitted option #159

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

nanobowers
Copy link
Collaborator

Fixes permitted range comparison issue. Previously the range would be turned into an array which could blow up memory.
Adds more tests for permitted behavior.

@miq-bot add-label enhancement test
@miq-bot add-reviewer @Fryguy

@nanobowers
Copy link
Collaborator Author

nanobowers commented May 23, 2024

The trick here was defining a method in each option type that converts/coerces the given value to from a string to the type of the option. This is used to to validate against the range.

Note to self: It would be nice to test endless ranges also, though some are invalid syntax for older rubies.
...And also to test for multi-value integer/float/string

@Fryguy
Copy link
Member

Fryguy commented May 24, 2024

Very clever! I love this.

@Fryguy Fryguy merged commit c2b3114 into ManageIQ:master May 24, 2024
12 checks passed
@Fryguy Fryguy self-assigned this May 24, 2024
Fryguy added a commit that referenced this pull request Nov 11, 2024
Added:
- Align the short and long forms into their own columns in the help output (#145 - thanks akhoury6)
- Add support for DidYouMean when long options are spelled incorrectly (#150 - thanks nanobowers)
- Using `permitted:` restricts the allowed values that a end-user inputs to a pre-defined list (#147 - thanks akhoury6)
- Add exact_match to settings, defaulting to inexact matching (#154 - thanks nanobowers)
- Add setting to disable implicit short options (#155 - thanks nanobowers)
- Add alt longname and multiple char support (#151 - thanks nanobowers)
- Permitted regexp/range support (#158, #159- thanks nanobowers)
- Add some examples (#161 - thanks nanobowers)

Changed:
- Enable frozen_string_literal for future-ruby support (#149, #153  - thanks nanobowers)
- Refactor constraints (#156 - thanks nanobowers)
- Fix assert_raises to assert_raises_errmatch (#160 - thanks nanobowers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants