-
Notifications
You must be signed in to change notification settings - Fork 23
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
Rc 0.6.0 #63
Conversation
@epage I think I'm done with rc 0.6.0 as far as new features and docs are concerned. You should be able to find up to date docs here: https://pacak.github.io/bpaf/bpaf/index.html Still open to suggestions on renames. One way would be to rename Next translating terms into open group base spec language
|
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.
Did a quick pass through so you could get this sooner than when i have time to be more thorough.
- `Positional` -> `ParsePositional` | ||
- `BuildArgument` -> `ParseArgument` | ||
- `Command` -> `ParseCommand` | ||
- `Named` -> `NamedArg` |
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.
Why Parse
prefixes for the first three but not for NamedArg
?
Personally, I would do
PositionalArg
Argument
Command
NamedArg
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.
Why Parse prefixes for the first three but not for NamedArg?
First three are actually parsers that can extract something, NamedArg
needs .flag
, .switch
or .argument
to become one. At the moment any primitive parser starts with Parse
so naming is consistent.
For Command
- when messing with passing arguments to cargo
I found it confusing when there's several things named Command
sitting in one namespace: one from bpaf
and one from std::process::Command
. Having distinct names helps to reduce this kind of confusion. I guess I'll poke my coworkers as well for the input.
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 renamed clap::App
to clap::Command
back in 3.1.0 and no one has brought up concerns over naming conflicts. Granted, it was only deprecated and in clap 3.2 we made deprecations opt-in. We'll see when clap v4 comes out.
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. For that to be reported you need a bunch of factors:
- One needs to try to pass some stuff to a child process which might be a problem in general: Partially parse args, capturing unknown args into a vec, rather than error clap-rs/clap#1404
- To do this in the same module as the argument parsing - I'm lazy and it's a prototype.
- Be actually bothered enough to report. I probably wouldn't be.
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.
(1) seems irrelevant. You just need to deal with Command
in the same mod. This can happen because of that, because of how cargo run --
works, or just because
(2) depends on if you do use clap::Command
. Personally, I don't. I only like using use
for traits.
With new additions you should be able to parse pretty much anything and then some more :) | ||
|
||
# Migration guide 0.5.x -> 0.6.x | ||
|
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.
One way would be to rename OptionParser into Parser - now that Parser is a trait they can coexist, and with hidden deprecated .run() in Parser trait to serve as a reminder - it should be harder to confuse those two I think. to_options is still a thing, with OptionParser renamed it can probably be changed to done/finish/make or add_info/with_info/and_info?
I would recommend against Parser
and Parser
as that can be confusing even if they do operate in different namespaces.
As for to_options
:
done
, et all implies it is built but it isn'tadd_info
focuses purely on adding context but there is more going on
I would focus on the core of what it is. It is taking the lower level parsers and wrapping / building / turning them into a full application / user-facing / std::env::args parser.
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.
You also go though OptionParser
when implementing commands and subcommands, making tests for your code or parsing things from sources other than std::env::args_os
. I think of it as a parser with some extra meta information attached. Interfacing with the lower level is done inside the run
method only - and that's the part that needs to be pluggable in order to support windows style flags FWIW.
and redo the exampels
Actual changes
What's new in 0.6.0
adjacent
restriction to parse things in a tighter contextcatch
formany
,some
andoptional
to handle parse errorsany
positional like, to consume pretty much anything from a command lineto_options
onParser
before trying to run itconstruct!
macro for making dynamic parsersconstruct!
macroWith new additions you should be able to parse pretty much anything and then some more :)
Migration guide 0.5.x -> 0.6.x
positional_os
andargument_os
withpositional
andargument
plus turbofish:from_str
with either turbofish on the consumer or withparse
, ifString
is generated inside the parser:FromOsStr
, alternativelyparse
still works:Positional
->ParsePositional
BuildArgument
->ParseArgument
Command
->ParseCommand
Named
->NamedArg