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

accept boolean arg pairs like "--arg-name true" #67

Merged
merged 4 commits into from
Feb 4, 2025

Conversation

jranson
Copy link
Contributor

@jranson jranson commented Jan 17, 2025

This PR allows CLI arguments like --idle-timeout-enabled false to work as expected. This format currently causes unexpected results for users, because the value must be in --arg=value format, otherwise the supplied boolean flag is resolved to true.

Specifically, this change scans the command tree for all boolean flags, identifies any present in the cli arguments that have a separate value arg (e.g., --idle-timeout-enabled false), and collapses them into single argument format (--idle-timeout-enabled=false) prior to being parsed by the Flag parser. This allows both the 2-arg and 1-arg versions of boolean flags to work identically based on the user's preference. This also enforces strconv.ParseBool's accepted formats (t, T, f, F, true, True, false, False, TRUE, FALSE, 0, 1) and reliably errors if the provided value is invalid.

@gwprice115 gwprice115 merged commit 1747420 into hathora:main Feb 4, 2025
13 checks passed
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.

3 participants