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 explicitly false booleans #276

Merged

Conversation

eugeneotto
Copy link
Contributor

@eugeneotto eugeneotto commented Sep 30, 2022

When a boolean option is explicitly set to false, e.g.:

--option=false

it enters slop as the string value 'false'. This commit updates the
BoolOption option handler to interpret 'false' and various other falsey
values (false, 'false', 'no', 'off', '0') as logically false.

@leejarvis
Copy link
Owner

Thanks for this change. I definitely support allowing a "false" value but I'm wondering whether we should support any other values? like no or 0 for example. WDYT? It might also be nice to have a FALSE_VALUES array within BoolOption and then just check for inclusion of explicit_value within this.

When a boolean option is explicitly set to `false`, e.g.:

```bash
--option=false
```

it enters slop as the string value `'false'`. This commit updates the
`BoolOption` option handler to interpret `'false'` and various other falsey
values (`false`, `'false'`, `'no'`, `'off'`, `'0'`) as logically false.
@eugeneotto
Copy link
Contributor Author

Thanks for the quick reply (and the great library)! I like that idea and updated the commit as suggested. I've also tweaked the README to document support for explicitly false boolean options.

@leejarvis
Copy link
Owner

leejarvis commented Sep 30, 2022

@eugeneotto this is excellent, thank you for the contribution! I'll get this pushed up as a bugfix release. (edit: released)

@leejarvis leejarvis merged commit 24d85e0 into leejarvis:master Sep 30, 2022
@eugeneotto eugeneotto deleted the fix-explicitly-false-booleans branch October 1, 2022 07:05
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Oct 12, 2022
https://build.opensuse.org/request/show/1010068
by user coolo + dimstar_suse
updated to version 4.9.3
 see installed CHANGELOG.md
  v4.9.3 (2022-09-30)
  -------------------

  Bug fixes:
    * Fix explicitly false boolean options and allow for additional false arguments [#276](leejarvis/slop#276) (Eugene Otto)
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