Comments (5)
I have updated clio with a clap-parse
feature to work with value_parser
it is in version 0.2.2
from clio.
(hey, @max-sixty!) Ah, looks like some more clap
api changes. Looking at https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#320---2022-06-13
- For default parsers (no
parse
attribute), deprecation warnings can be
silenced by opting into the new behavior by adding either#[clap(action)]
or#[clap(value_parser)]
(ie requesting the default behavior for these
attributes). Alternatively, theunstable-v4
feature changes the default
away fromparse
toaction
/value_parser
.- For
#[clap(parse(from_flag))]
replaced with#[clap(action = ArgAction::SetTrue)]
(#3794)- For
#[clap(parse(from_occurrences))]
replaced with#[clap(action = ArgAction::Count)]
though the field's type must beu8
(#3794)- For
#[clap(parse(from_os_str)]
forPathBuf
, replace it with
#[clap(value_parser)]
(as mentioned earlier this will call
value_parser!(PathBuf)
which will auto-select the rightValueParser
automatically).- For
#[clap(parse(try_from_str = ...)]
, replace it with#[clap(value_parser = ...)]
- For most other cases, a type implementing
TypedValueParser
will be needed and specify it with#[clap(value_parser = ...)]
Thanks for the nifty little library by the way! If you are interested in maintaining compatibility with these clap
changes, I'm happy to suggest a patch.
from clio.
@max-sixty it also looks like these deprecation warnings are turned off in the latest version of clap
Cargo checks are passing for PRQL/prql#598 which uses this latest version 👍
from clio.
Thanks a lot @kwigley !
from clio.
@kwigley I was looking forward to this clap update as it fixes the issue I had with try_from being called twice. I am looking to support the #[clap(value_parser)]
syntax.
The only drawback is that to work with value_parser
the type needs to be Clone
, Send
, and Sync
. File
is not Clone
and the Http clients (if that feature is enabled) are not Sync
.
My current plan is to implement clone by calling File::try_clone
and panicing if it does not work. I don't like the panic and I don't like that the clones share a handle and therefore file position but I don't have a better answer. However using the derive syntax clap never calls clone, so it is not really an issue.
from clio.
Related Issues (17)
- Doesn't play nicely with clap 3.1's derive API HOT 2
- Compatibility with Clap 4? HOT 4
- Feature-gated functionality not marked in docs HOT 1
- Errors displayed poorly HOT 1
- Clap 4.1.0 compat HOT 2
- FYI — directories / `clio_extended` HOT 6
- Atomic write support? HOT 1
- More configuration options on `OsStrParser` (maybe making it a "PathParser`?) HOT 1
- does not compile on rust 1.65.0
- Make seek work with HTTP range requests
- Make seek work with stdin/stdout
- remove Deref<Path> from ClioPath
- Fix length for block devices
- Add directory arg support HOT 7
- exists() on "." always returns true even if the current working directory has been deleted.
- Github tags HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clio.