- make sure env-only arguments and flags are working
- support raw identifiers in derive macro (#282)
- better error messages for unexpected values that prevent positional parses
- bugfix in completions generator for bash thanks @akinomyoga
choice
combinator to efficiently construct alternative parsers at runtime
- fancier squashing: parse
-abfoo
as-a -b=foo
if b is a short argument bpaf_derive
: make sure command aliases are actually working
- add
help
toParseFlag
andParseArgument
- stop deprecating
Parser::run
- Lots of docs.rs documentation improvements
- changes to rendered markdown
Parser::collect
allows to collect multiple items into an arbitraryFromIterator
collection- Bugfix in parsing for unit structs
- docs.rs documentation update
- with
docgen
feature you can render documentation as markdown - cosmetic changes to error messages
- add a way to print usage when called with no argument_os
- since 0.9.0 bpaf splits help messages into "full" and "partial", displaying
full only when
--help
flag is passed twice or when rendering the documentation, see https://docs.rs/bpaf/0.9.0/bpaf/parsers/struct.NamedArg.html#method.help display_fallback
anddebug_fallback
now can be used withfallback_with
- regression fixes
- more errors are now passed as ADTs rather than plain strings
- conflicts are now tracked with indices rather than parser meta
- documentation improvements
- better error messages
- smaller generated binary
bpaf_derive 0.5.0
comes with some breaking changes- documentation generation now comes under
docgen
feature instead ofmanpage
and some things are renamed - standalone
command
function was deprecated in favor of.command
method onOptionParser
- hidden no-op helper type
FromUtf8
was removed - "{usage}" override is removed in favor of new
OptionParser::with_usage
should be faster to compile and a bit more flexible with respect to what is accepted
- explicit
construct
annotation is gone and used by default ifoptions
andcommand
are missing options
andcommand
now must be specified at the beginning of#[bpaf(...
macrodefault
annotation for enum variants is gone, you can usefallback
on top instead
- combination of
command
andhide
now works as expected inbpaf_derive
any
now takes a function that checks if it matches the input or not. You can still apply usual filtering withguard
, etc after it but initial filtering inside a function leads to better error messages.anywhere
is now a method onany
instead of being a parser method and should now be used to make an arbitrary looking flag like parsers. You can still parse blocks from arbitrary places using remainingadjacent
methodmany
andsome
will now collect one result from a parser that does not consume anything from an argument list allowing for easier composition with parsers that consume from both command line and environment variables. If your code depends on the original behavior you should replace non failing parsers undermany
with failing parsers:req_flag
instead ofswitch
.
- parsing combinators
many
,some
,optional
andanywhere
will now propagate parsing errors outwards, you can regain the old behvior by specifyingcatch
- better error messages related to
anywhere
parsers anywhere
parsers are now given an attempt to consume an empty list- support deriving
req_flag
consumers - support deriving
catch
annotation - errors generated by
some
can now be handled withfallback
/fallback_with
- fallback values can be made visible in
--help
withdisplay_fallback
/debug_fallback
bpaf_derive
: top level doc comments on a regular parser are now turned into agroup_help
- better error messages for invalid user input
- env fallback can now be fully hidden
- meta description refactor - invididual parsers should be described more consistently in all sorts of messages
- better error messages with positionals and inside anywhere blocks
- if you used
any
to consume items without validations just passSome
as a parameter and add two wildcard generic type parameters:-let rest = any<OsString>("RESt").many(); +let rest = any<OsString, _, _>("REST", Some);
- If you used
any
with extra validation to decide if something should be consumed at all you can move this validation inside of any. If validation fails - any behaves as if this argument wasn't specified at all:-let name = any("NAME").guard(|x| x == "Bob", "Only Bob is allowed").optional().catch(); +let name = any("NAME", |x| (x == "Bob").then_some(x));
- You can replicate most of the behavior from old
anywhere
modifier with newadjacent
:-let set = construct!(set, name, value).anywhere(); +let set = construct!(set, name, value).adjacent();
- If you previously used
switch
or an option with fallback in combination withmany
you need to replaceswitch
with something that needs at least one item and move fallback outside:-let verbose = short('v').switch().many().map(|x| x.len()); +let verbose = short('v').req_flag(()).many().map(|x| x.len());
- improve error messages for typos like
-llvm
instead of--llvm
- improve error messages when a flag is accepted by a command but not directly
- allow to derive position bool
- derive anywhere and boxed
- dynamic layout for --help messages
- bump syn to 2.0
ParseFailure::exit_code
- A way to specify custom usage in derive macro
- manpage generation bugfixes, thanks to @ysndr
- internal cleanups
- avoid impossible shell completions
- manpage generation
- fix docs.rs issues
- improve error messages when several conflicting options are specified
- improve category theory docs
- improve docs for batteries
- bpaf_derive: improve error message
- bpaf: bugfix for bash static shell completion
try_run
thanks to @ysndr-Obits=2048
is now parsed as short flagO
with a value ofbits=2048
instad of crashingcomplete_shell
- a way to call to static shell completion functions, bash and zsh only for now
- drop tainting logic, should be redundant
- improve error messages for guard and conflicting branches
- colors similar to cargo'some thanks to @kramer425
- support for empty structs/enums in
construct!
pure_with
implementation thanks to @xitepFromOsStr
is replaced with magical uses ofAny
traithide_usage
bright-color
anddull-color
features- accept fully qualified names in more places in
bpaf_derive
- cosmetic improvements
- documentation improvements
- Remove FromUtf8 annotations if you have any
In many cases rustc should be able to derive what the type
-let coin = short('c').argument::<FromUtf8<Coin>>("COIN"); +let coin = short('c').argument::<Coin>("COIN");
- Replace
FromOsStr
implementations for your types withFromStr
if you have any. If your type requires parsingOsString
directly you can perform it in two steps - consumingOsString
+ parsing it withParser::parse
- If you want to provide your users with colored output - expose
bright-color
and/ordull-color
features
- cosmetic improvements
- completion info in
sensors
example - better errors in partially consumed optional items
- better handling of -- during autcomplete
- initial release of
bpaf_cauwugo
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 line- improved documentation with more detailed examples
- cosmetic improvements
- a sneaky reminder to use
to_options
onParser
before trying to run it - removed OsString specific
positional_os
andargument_os
- a way to make boxed parsers with single item
construct!
macro for making dynamic parsers - a horrible way to reduce Yoda-talk coding by placing primitive definitions inside the
construct!
macro
With new additions you should be able to parse pretty much anything and then some more :)
- Replace any uses of
positional_os
andargument_os
withpositional
andargument
plus turbofish:-let file = positional_os("FILE").help("File to use").map(PathBuf::from); +let file = positional::<PathBuf>("FILE").help("File to use");
- Replace any uses of
from_str
with either turbofish on the consumer or withparse
, ifString
is generated inside the parser:You can still use it for your own types if you implement-let number = short('n').argument("N").from_str::<usize>(); +let number = short('n').argument::<usize>("N");
FromOsStr
, alternativelyparse
still works:-let my = long("my-type").argument("MAGIC").from_str::<MyType>(); +let my = long("my-type").argument::<String>("MAGIC").parse(|s| MyType::from_str(s));
- You shouldn't be using those names directly in your code, but there are some renames
Positional
->ParsePositional
BuildArgument
->ParseArgument
Command
->ParseCommand
Named
->NamedArg
- bugfix with zsh autocomplete #46
- reimplement bpaf derive - should be faster to compile and easier to work with
- minor doc fixes
- bugfix for dynamic completion
- invariant checker - for tests
- more error message improvements
- non-utf8 support in --foo=bar / -f=bar
- dynamic shell completion: bash, zsh, fish, elvish
- toggle flag battery
- templated usage string: can use "{usage}" in custom overrides
minor bugfixes
- more consistent alternative selection
- handle "missing" inside a subparser
and a bit more cosmetics - preserve suggestion context when returning from a subcommand
- fix a regression in error messaged caused by 0.5.1
- guard now displays the problematic input if it's a single argument issue
improve error messages if argument parsing fails:
- matcher no longer escapes inner command if it gets there
- detect and try to suggest for possible typos
A big rewrite, performance should stay mostly unchanged, binary overhead should be down by a third or so. Some minor cosmetic and correctness changes. Documentation rewrite.
Migration guide:
- add
use bpaf::Parser;
if you don't have it already - it is now a trait and needs to be in scope - replace
fn foo() -> Parser<T>
withfn foo() -> impl Parser<T>
- replace
Info::default().descr("xxx").for_parser(parser)
withparser.to_options().descr("xxx")
- replace
a.or_else(b).or_else(c) with
construct!([a, b, c])` - replace
command("foo", Some("bar"), subparser)
withsubparser.command("foo").help("bar")
- bpaf now depends on a specific version of bpaf_derive
- meta and item refactors, changed the formatting a bit
- docs type: option -> optional
- metavar name for positional, positional_os, argument, argument_os is now optional
- bpaf_derive is now more strict about derive attribute parsing
- derived items can be made module private
- env is now supported
- bugfix for custom usage formatting
- bugfix for help rendering with fallback
- support for env
- support arbitrary long paths in construct! macro
- use $crate:: inside construct to allow using it without importing
- lower minimum supported rustc version to 1.56
- deriving for version should be working now
- version now uses -V instead of -v
- support for version and version(expr) annotations on a top level
- improve help generation from doc comments
- derive macro
- some takes an error message
- support for or_else construct!([alt1, alt2, alt3])
- cargo_helper, hide + cosmetic bugfixes
- parsers produced by functions inside construct!() macro
- optimizations
- renamed Parser::help to Parser::group_help to reduce confusion
- publish API for users to write tests for parsers