Giter Club home page Giter Club logo

promkit's Introduction

Github linkedin speakerdeck twitter

github-stats

promkit's People

Contributors

anton-suprun avatar samoylovfp avatar undyingsoul avatar ynqa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

promkit's Issues

Checkbox::new_with_checked

Nice project! I would love to use it (it looks stunning!). However for my use case I want to run the checkbox prompt with some items pre-selected. I think this is common enough to fit the checkbox preset.

existing work:
dialoguer has MultiSelect::items_checked.

selectbox::SelectBox not found

Hi,

I'm trying to run the second example (the first one works), and I receive the following compilation error:

error[E0432]: unresolved import `promkit::selectbox`
 --> src/main.rs:6:55
  |
6 |     build::Builder, crossterm::style, Result, select, selectbox::SelectBox
  |                                                       ^^^^^^^^^ could not find `selectbox` in `promkit`

I'm working on version 0.1.1 on rust 1.62

Validator type doesn't allow capture of external variables

Since type Validator<T> = fn(&T) -> bool;, i can't do something like:

let existing_filenames = read_dir(...);

Readline::default()
    .title("Name new file:")
    .validator(|name| !existing_filenames.contains(name.to_string()), |name| format!("File {} already exists", name))
    .prompt()?
    .run()?;

Suggest swapping this to something like type Validator<T> = Box<dyn Fn(&T) -> bool>;

Compilation fails on Windows

Thank you for making this library, it looks very nice!

Unfortunately, fake_input uses os::unix, preventing compilation on Windows.

I don't know if what fake_input does is possible in a cross-platform fashion, but since it appears to be a utility for testing, and not essential to the library itself, maybe the module could, for now, be omitted on Windows via cfg?

Derive a form (multiple prompts) from struct

I would like to easily annotate a configuration struct, to ask the user for input for various fields and give a hint on validation:

use derive_bla::AskUser;

#[derive(Debug, AskUser)]
struct MyConf {
    #[ask(q="Please enter password:", hide_input=true, min_len=12)]
    password: Option<String>,

    #[ask(q="Please enter username:", min_len=3)]
    username: Option<String>,

    #[ask(q="Please enter age:", range=18..=85)]
    age: Option<u8>,
}

fn main() -> Result<()> {
    let mut conf = MyConf::default()
    conf.password()?.validate()?;
    conf.username()?.validate()?;
    conf.age()?.validate()?;

    println!("{conf#?}");
}

I would be interested if something like this is already existing, e.g. based on inquire, promkit, or if there is any interest to add this?

There are some ideas already in inquire, but it feels a bit out of scope.

CC: mikaelmello/inquire#212
CC: mikaelmello/inquire#65

EDIT: It would basically be the clap way of doing interactive prompts. Annotate something and give it to the user to let it be filled out. I think it comes with its own advantages and disadvantages, and excels a lot in a workflow where you suddenly want the user to fill out some data you already have bundled in a struct.

I think it could be a game changing feature, though. Because it would make dealing with interactive prompts much easier for a lot of users. Also, it would be excellent to have for people that don't want the full-fledged control of a ratatui TUI, but still a bit more ergonomic when it comes to interactivity and developer experience creating such.

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.