-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add -C
flag to build command
#734
Conversation
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 direction looks good to me! Left some thoughts and minor comments.
NoSourceCompression(bool), | ||
} | ||
|
||
impl FromStr for CodegenOption { |
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.
We had briefly discussed using https://docs.rs/clap/latest/clap/builder/trait.ValueParserFactory.html -- although the current approach seems to work well enough for the current PR. We can always iterate and refactor later.
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.
I should've mentioned in the description, I looked briefly at using it. My understanding is it works well if you need to keep track additional state outside of parsing the string to whatever type you're parsing it too. But the tradeoff is it forces you to define an additional type for the parser for the value, which is one more type to define. Ultimately since we have to collect a vector of something, I figured it would be easier to just write the state we need to collect to that something. That said, if we want to ensure there are no duplicate keys present and error out in the option collection phase, then having a custom parser would make that possible. Right now if an option is specified more than once, it'll take the last value as the one to use.
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.
That said, if we want to ensure there are no duplicate keys present and error out in the option collection phase, then having a custom parser would make that possible
In the long run, I think we'd want to ensure this.
A custom parser also gives you more control over how to define/manage your group options and group help (e.g., you can have the help be automatically generated from the options without having to manually update the help string manually every time, which might be error prone).
I think it's fine to leave it as it for this first iteration, we can always refactor later.
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.
A custom parser also gives you more control over how to define/manage your group options and group help (e.g., you can have the help be automatically generated from the options without having to manually update the help string manually every time, which might be error prone).
Do you mean defining an implementation for possible_values
?
Description of the change
I want to get early feedback on adding support for the
-C
flag documented in #702 so I can iterate on the draft as we figure out what makes sense to change.There's a few changes:
CompileAndBuildCommandOpts
->CompileCommandOpts
andBuildCommandOpts
including splitting out the handling of thecompile
and build` subcommands.BuildCommandOpts
introduces a few extra types to try and get the repeated-C
flags to play nicely withclap
. There's a lot of copying triple slash comments around, none of it is picked up byclap
so not sure if there's something better we can do. I looked at implementingValueEnum
as well but it looks like that's intended only for enums with entirely unit variants. There's also a manual step to translate theVec<CodegenOption>
toCodegenOptionGroup
sinceclap
out-of-the-box only allows specifying the-C
flag multiple times if the type associated with the option is aVec
.javy-runner
to default to using thebuild
command and support the argumentsbuild
supports unless a method has been invoked on the builder to usecompile
instead. I'm open to a different API.run_with_compile_and_build
to most tests to check that the build and compile commands function correctly. This could make more sense as a macro, I thought I'd start with a function because IMO it's easier to follow what the code is doing.Why am I making this change?
#702
Checklist
javy-cli
andjavy-core
do not require updating CHANGELOG files.