Giter VIP home page Giter VIP logo

Comments (4)

mikaelmello avatar mikaelmello commented on May 30, 2024

cc @JaciBrunning, it would be great to have some input on what kind of APIs you'd consider good for this use case

from inquire.

mikaelmello avatar mikaelmello commented on May 30, 2024

wdyt of this API?

https://github.com/mikaelmello/inquire/blob/main/examples/enum_select_raw.rs

I didn't want to depend on any strum-specific features, but with #9 it becomes very easy to select enums, you only need to have a vector of them and a Display implementation.

from inquire.

JaciBrunning avatar JaciBrunning commented on May 30, 2024

Looks good to me - I like the use of the Display trait instead of requiring a collection of strs - makes this whole thing more accessible (and easier for non-enum types, too - especially mapping back to the original value). Looks like it should work pretty easily if the developer has strum already, too. Thanks!

from inquire.

mikaelmello avatar mikaelmello commented on May 30, 2024

I'm glad you liked it!

I tried strum a little bit and the only point I found that does not match well with this approach is that the trait that creates VARIANTS makes it an array of strings, requiring some bit of conversion (when creating a prompt or storing the Vec somewhere 'global')

I'll consider this closed then, let me know if you have any issues or suggestions!

from inquire.

Related Issues (20)

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.