(Translated by https://www.hiragana.jp/)
Fix property parsing bug in the cli by stackoverflow · Pull Request #596 · apple/pkl · GitHub
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 property parsing bug in the cli #596

Merged
merged 2 commits into from
Jul 25, 2024

Conversation

stackoverflow
Copy link
Contributor

This fixes a bug where a property set as -p foo= would be parsed as "true" instead of "".

@StefMa
Copy link
Contributor

StefMa commented Jul 24, 2024

Why is that a bug? 🤔
I wouldn't expect to have set a property to true if only prop= is set.
Maybe it should report an error instead of using a blank string? 🤔

@stackoverflow
Copy link
Contributor Author

Why is that a bug?

Because before this fix you couldn't set a property to empty string.

Maybe it should report an error instead of using a blank string?

Why would this be an error? Empty string is a valid property value.

@StefMa
Copy link
Contributor

StefMa commented Jul 24, 2024

Got it. I misunderstood the implementation 😂
This is fine 👌

@@ -45,10 +45,10 @@ class BaseCommandTest {

@Test
fun `external properties without value default to 'true'`() {
cmd.parse(arrayOf("-p", "flag1", "-p", "flag2", "-p", "FOO=bar"))
cmd.parse(arrayOf("-p", "flag1", "-p", "flag2=", "-p", "FOO=bar"))
Copy link
Contributor

Choose a reason for hiding this comment

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

The flag1 and flag2 test cases becoming overlapped should have been a hint before ;)

Copy link
Contributor

@bioball bioball left a comment

Choose a reason for hiding this comment

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

LGTM

@stackoverflow stackoverflow merged commit e3133f6 into apple:main Jul 25, 2024
5 checks passed
@stackoverflow stackoverflow deleted the fix-cli-properties branch July 25, 2024 07:27
bioball pushed a commit that referenced this pull request Aug 6, 2024
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.

4 participants