Skip to content

Conversation

@gilramir
Copy link
Contributor

@gilramir gilramir commented Feb 1, 2026

Instead of splitting the command-line on whitespace, and looking for "--flag=value" strings to find the flags, step through all the arguments to that "--flag=value" and "--flag value" (as separate arguments) can be handled.

This also adds the convention seen in many POSIX tools whereby the "--" string stops optional flag processing, and everything after it is considered a positional argument.

This implementation does not allow separated values that start with "--", as in "--output --legal-filename". That produces an error. If the user really wants to do that, they can use the version with the equals sign: "--output=--legal-filename"

Instead of splitting the command-line on whitespace, and looking
for "--flag=value" strings to find the flags, step through
all the arguments to that "--flag=value" and "--flag value" (as
separate arguments) can be handled.

This also adds the convention seen in many POSIX tools whereby
the "--" string stops optional flag processing, and everything
after it is considered a positional argument.

This implementation does not allow separated values that start
with "--", as in "--output --legal-filename". That produces an error.
If the user really wants to do that, they can use the version
with the equals sign: "--output=--legal-filename"
@gilramir
Copy link
Contributor Author

gilramir commented Feb 1, 2026

The one "code smell" here is that instead of adding a notion of "does this flag require a value", I'm keying off of the "title" field in the FlagParserDescription. A toggle flag has an empty title, whereas non-toggle flags do not. If we want to improve that, FlagParserDescription should change.

I added new unit tests, which pass. I am unable to build a gren 0.6.3 compiler with this package, however.
How does one get around the dependency problems?
In gren 0.6.3's compiler.git, gren.json requires gren-version 0.5.3. But in compiler-node.git, gren.json requires gren-version "0.6.0 <= v 0.7.0".

@robinheghan
Copy link
Member

Yeah, the compiler app hasn't been updated to the latest version of Gren, so unit tests will have to do for now :)

@robinheghan
Copy link
Member

Thanks!

@robinheghan robinheghan merged commit c92bf95 into gren-lang:main Feb 2, 2026
2 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.

2 participants