Git Product home page Git Product logo

Comments (5)

aj-bagwell avatar aj-bagwell commented on July 23, 2024 2

I have updated clio with a clap-parse feature to work with value_parser it is in version 0.2.2

from clio.

kwigley avatar kwigley commented on July 23, 2024

(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, the unstable-v4 feature changes the default
    away from parse to action/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 be u8 (#3794)
  • For #[clap(parse(from_os_str)] for PathBuf, replace it with
    #[clap(value_parser)] (as mentioned earlier this will call
    value_parser!(PathBuf) which will auto-select the right ValueParser
    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.

kwigley avatar kwigley commented on July 23, 2024

@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.

max-sixty avatar max-sixty commented on July 23, 2024

Thanks a lot @kwigley !

from clio.

aj-bagwell avatar aj-bagwell commented on July 23, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.