Skip to content

v0.3.0

Latest
Compare
Choose a tag to compare
@blyxxyz blyxxyz released this 16 Jan 20:38
· 13 commits to master since this release

This release adds a new preferred way to cast OsString into String (.string()?) and makes raw argument processing more flexible.

Almost no programs should need changes to keep working, but .string()? makes it easier to use lexopt with other error types like anyhow's and using it is therefore recommended.

New:

  • Add ValueExt::string() as the preferred method for converting from OsString into String. Unlike OsString::into_string() it has a normal error type so it's compatible with catch-all error types like anyhow::Error. (#10)
    • into_string()? will stay supported for the time being.
  • Add RawArgs::as_slice() for unlimited lookahead. (#15)
  • Add Parser::try_raw_args() to get raw arguments without consuming any arguments in case of failure.
  • Parser now implements Clone, Send, and Sync. Its Debug output now shows the remaining arguments.

Changes:

  • The input iterator is now consumed when you create a Parser, instead of during parsing. This breaks certain clever code that inspects the state of the iterator, but RawArgs::as_slice() may provide an alternative. (If you don't know what this means then you aren't affected.) (#16)
  • Calling Parser::values() no longer consumes any arguments if you don't use the iterator.
  • RawArgs::peek() now takes &self instead of &mut self.