-
Notifications
You must be signed in to change notification settings - Fork 132
[ZLI][UX]: Support = in parameters, and better error messages (#24) #325
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
Open
zhiningli
wants to merge
1
commit into
facebook:dev
Choose a base branch
from
zhiningli:zli-equals-syntax-support
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+271
−16
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e21826f to
3af33e9
Compare
|
@zhiningli has imported this pull request. If you are a Meta employee, you can view this in D89766246. |
zhiningli
added a commit
to zhiningli/openzl
that referenced
this pull request
Dec 24, 2025
…acebook#325) Summary: This PR addresses issue facebook#24 by adding support for the --flag=value syntax in the ZLI command-line interface. Changes: - Updated processLongFlag to parse = syntax, extracting flag name and value separately - Added validation to reject =value for boolean flags that don't accept values - Refactored duplicate error message construction into helper lambdas (formatFlagName, checkDuplicateFlag) following DRY principles - Reduced nesting in processLongFlag using early returns for better readability - Added 9 unit tests covering various scenarios - Added Buck and CMake build configurations for tests - Fixed BUCK file syntax error (missing comma) and converted to relative paths - Updated usage message to document the = syntax Both syntaxes are now supported: - `--profile=u32` (new) - `--profile u32` (existing) Test Plan: Run unit tests with Buck: ``` buck2 test fbcode//openzl/dev/tools/arg/tests:arg_parser_test ``` All 9 tests pass: - LongFlagWithEqualsSign - LongFlagWithSpaceSeparatedValue - BothSyntaxesProduceSameResult - EqualSyntaxWithMultipleValues - MixedSyntax - BooleanFlagWithoutValue - ValueContainingSpecialCharacters - BooleanFlagWithEqualsValueThrows - UnknownFlagWithEquals Differential Revision: D89766246 Pulled By: zhiningli
3af33e9 to
c383a48
Compare
|
@zhiningli has exported this pull request. If you are a Meta employee, you can view the originating Diff in D89766246. |
c383a48 to
03f382b
Compare
zhiningli
added a commit
to zhiningli/openzl
that referenced
this pull request
Feb 7, 2026
…acebook#325) Summary: This PR addresses issue facebook#24 by adding support for the --flag=value syntax in the ZLI command-line interface. Changes: - Updated processLongFlag to parse = syntax, extracting flag name and value separately - Added validation to reject =value for boolean flags that don't accept values - Added validation to reject empty value after = (e.g. --profile=) for flags that require a value - Refactored duplicate error message construction into helper lambdas (formatFlagName, checkDuplicateFlag) following DRY principles - Simplified processLongFlag control flow using early returns - Added 10 unit tests covering various scenarios including empty = value - Added Buck and CMake build configurations for tests - Fixed BUCK file syntax error (missing comma) and converted to relative paths - Updated usage message to document the = syntax Both syntaxes are now supported: - `--profile=u32` (new) - `--profile u32` (existing) Test Plan: Run unit tests with Buck: ``` buck2 test fbcode//openzl/dev/tools/arg/tests:arg_parser_test ``` All 10 tests pass: - LongFlagWithEqualsSign - LongFlagWithSpaceSeparatedValue - BothSyntaxesProduceSameResult - EqualSyntaxWithMultipleValues - MixedSyntax - BooleanFlagWithoutValue - ValueContainingSpecialCharacters - BooleanFlagWithEqualsValueThrows - UnknownFlagWithEquals - EqualsWithEmptyValueThrows Differential Revision: D89766246 Pulled By: zhiningli
zhiningli
added a commit
to zhiningli/openzl
that referenced
this pull request
Feb 7, 2026
…acebook#325) Summary: This PR addresses issue facebook#24 by adding support for the --flag=value syntax in the ZLI command-line interface. Changes: - Updated processLongFlag to parse = syntax, extracting flag name and value separately - Added validation to reject =value for boolean flags that don't accept values - Added validation to reject empty value after = (e.g. --profile=) for flags that require a value - Refactored duplicate error message construction into helper lambdas (formatFlagName, checkDuplicateFlag) following DRY principles - Simplified processLongFlag control flow using early returns - Added 10 unit tests covering various scenarios including empty = value - Added Buck and CMake build configurations for tests - Fixed BUCK file syntax error (missing comma) and converted to relative paths - Updated usage message to document the = syntax Both syntaxes are now supported: - `--profile=u32` (new) - `--profile u32` (existing) Test Plan: Run unit tests with Buck: ``` buck2 test fbcode//openzl/dev/tools/arg/tests:arg_parser_test ``` All 10 tests pass: - LongFlagWithEqualsSign - LongFlagWithSpaceSeparatedValue - BothSyntaxesProduceSameResult - EqualSyntaxWithMultipleValues - MixedSyntax - BooleanFlagWithoutValue - ValueContainingSpecialCharacters - BooleanFlagWithEqualsValueThrows - UnknownFlagWithEquals - EqualsWithEmptyValueThrows Differential Revision: D89766246 Pulled By: zhiningli
03f382b to
d777a1c
Compare
…acebook#325) Summary: This PR addresses issue facebook#24 by adding support for the --flag=value syntax in the ZLI command-line interface. Changes: - Updated processLongFlag to parse = syntax, extracting flag name and value separately - Added validation to reject =value for boolean flags that don't accept values - Added validation to reject empty value after = (e.g. --profile=) for flags that require a value - Refactored duplicate error message construction into helper lambdas (formatFlagName, checkDuplicateFlag) following DRY principles - Simplified processLongFlag control flow using early returns - Added 10 unit tests covering various scenarios including empty = value - Added Buck and CMake build configurations for tests - Fixed BUCK file syntax error (missing comma) and converted to relative paths - Updated usage message to document the = syntax Both syntaxes are now supported: - `--profile=u32` (new) - `--profile u32` (existing) Test Plan: Run unit tests with Buck: ``` buck2 test fbcode//openzl/dev/tools/arg/tests:arg_parser_test ``` All 10 tests pass: - LongFlagWithEqualsSign - LongFlagWithSpaceSeparatedValue - BothSyntaxesProduceSameResult - EqualSyntaxWithMultipleValues - MixedSyntax - BooleanFlagWithoutValue - ValueContainingSpecialCharacters - BooleanFlagWithEqualsValueThrows - UnknownFlagWithEquals - EqualsWithEmptyValueThrows Differential Revision: D89766246 Pulled By: zhiningli
d777a1c to
fdf7032
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #24 by adding support for the --flag=value syntax in the ZLI command-line interface.
Changes:
tools/arg/arg_parser.cpp: Updated processLongFlag to parse = syntax, extracting flag name and value separately. Added validation to reject =value for boolean flags that don't accept values.tools/arg/tests/arg_parser_test.cpp: Added 9 unit tests covering various scenarios.tools/arg/tests/BUCK: Added Buck build configuration for the new tests.tools/arg/CMakeLists.txt: Added CMake test configuration using gtest.cli/zli.cpp: Updated usage message to document the = syntax.Before:
After:
Both syntaxes are now supported:
Test Plan:
Run unit tests with CMake:
Expected output: