-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[std] add minimal CLI parser std.cli
#24881
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
622264b
[std] add minimal CLI parser `std.cli`
thejoshwolfe 8cb3eb3
add more test params i guess
thejoshwolfe 7b386cc
add options.exit_on_error
thejoshwolfe f27e564
exit(0) on --help
thejoshwolfe c6f3e4b
use correct error type
thejoshwolfe f2753f5
change positional to a struct
thejoshwolfe 9df8a48
nicer usage
thejoshwolfe bc05dc4
typo
thejoshwolfe 5278e4d
fix tests
thejoshwolfe 96f353f
help for positional
thejoshwolfe 473c1d6
support extra help decoration
thejoshwolfe 69c1dbc
update tools/ to use std.cli.parse
thejoshwolfe 8de26d5
add tests for new help stuff
thejoshwolfe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a glance it might be nicer to instead type it
?[]const u8and default tonull.Then the code wouldn't have to check for length 0, and could use
orelseinstead.iiuc, passing
--sysroot=""leads to auto-detection, with that change I assume it would lead to an error and have to be omitted.Is there a code or interface reason that I'm missing that makes
""more intuitive for auto-detection?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason is that i ported code that was expecting
nullafter argument parsing, and so i preserved those semantics. optional arguments declared as?[]const u8 = nullmakes a lot of intuitive sense, but i explained why i believe it is a misfeature in #24601.it could be that the pattern here will be frequent where users want to conflate
""withnull, like i'm doing, but a layer of code to translate from a deserialization system into the type you want to use in your code base is a common thing that doesn't mean the deserialization system is missing a feature.if you disagree that lack of support for
nullis a misfeature, let's discuss it #24601. the real actual use cases you're pointing to in this review are evidence against my stance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, are you saying that
""is different that not being specified? if so, then i've broken something. i'll take a look.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, i can't tell whether
cc -isysroot ''is going to do something meaningful, so i don't know if i broke it or not. on my system, i get this:based on the name and lack of comments (git log didn't help either), i guess this is supposed to run on MacOS perhaps? pinging @alexrp to shed insight. is
--sysroot=""supposed to be different from omitting the--sysrootargument entirely?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, my bad, should have been more specific - I was just talking about the behavior of the new code.
I'm not familiar with the old behavior either, but think it's unlikely that
""had any special meaning/behavior previously.