Giter Site home page Giter Site logo

enquirer's Introduction

enquirer

Zulip Crates.io

Command line utility for stylish interactive prompts
(uses dialoguer underneath)

Getting started

Get started with Enquirer, the most powerful command line utility for creating interactive CLI prompts.

Install

enquirer is available on Linux, macOS

$ brew install termapps/tap/enquirer

This is recommended way for installation on macOS since updating to the new version is easy.

With cargo

$ cargo install enquirer

Direct

Pre-built binary executables are available at releases page for macOS (64bit), Linux (64bit, 32bit).

Download and unarchive the binary then put the executable in $PATH.

Check roadmap for other ways

Usage

Command Line Utility

The main reason I created this tool is to use it as an stylish interactive and user-friendly prompt for bash scripting.

#!/bin/bash

confirm=$(enquirer confirm -m "Do you want to continue?" -d)

if [ "$confirm" = "true" ]; then
    echo "Continuing ..."
else
    echo "Thanks for using this tool. Quitting ..."
    exit
fi

See prompts for more information on subcommands.

enquirer 0.5.1
Command Line Utility for Stylish Interactive Prompts

USAGE:
    enquirer [FLAGS] <SUBCOMMAND>

FLAGS:
    -h, --help        Prints help information
        --no-color    Disable colors in the prompt
    -V, --version     Prints version information

SUBCOMMANDS:
    confirm         Prompt that returns `true` or `false` (as strings)
    help            Prints this message or the help of the given subcommand(s)
    input           Prompt that takes user input and returns a string
    multi-select    Prompt that allows the user to select multiple items from a list of options
    secret          Prompt that takes user input, hides it from the terminal, and returns a string
    select          Prompt that allows the user to select from a list of options
    sort            Prompt that allows the user to sort items in a list

Prompts

Confirm Prompt

Prompt that returns true or false (as strings)

Enquirer Confirm Prompt

Usage

enquirer-confirm 0.5.1
Prompt that returns `true` or `false` (as strings)

USAGE:
    enquirer confirm [FLAGS] --message <message>

FLAGS:
    -c, --cancel     Makes the prompt cancellable with 'Esc' or 'q'
    -d, --default    Sets the default value for the prompt as `true`
    -h, --help       Prints help information

OPTIONS:
    -m, --message <message>    Message for the prompt

Input Prompt

Prompt that takes user input and returns a string

Enquirer Input Prompt

Usage

enquirer-input 0.5.1
Prompt that takes user input and returns a string

USAGE:
    enquirer input [FLAGS] [OPTIONS] --message <message>

FLAGS:
    -a, --allow-empty    Allow empty input. Conflicts with `default`
    -h, --help           Prints help information

OPTIONS:
    -d, --default <default>    Default value for the prompt
    -m, --message <message>    Message for the prompt

Secret Prompt

Prompt that takes user input, hides it from the terminal, and returns a string

Enquirer Secret Prompt

Usage

enquirer-secret 0.5.1
Prompt that takes user input, hides it from the terminal, and returns a string

USAGE:
    enquirer secret [FLAGS] [OPTIONS] --message <message>

FLAGS:
    -a, --allow-empty    Allow empty secret
    -h, --help           Prints help information

OPTIONS:
    -c, --confirm <confirm>    Enable confirmation prompt with this message
    -e, --error <error>        Error message when secrets doesn't match during confirmation
    -m, --message <message>    Message for the prompt

Select Prompt

Prompt that allows the user to select from a list of options

Enquirer Select Prompt

Usage

enquirer-select 0.5.1
Prompt that allows the user to select from a list of options

USAGE:
    enquirer select [FLAGS] [OPTIONS] --message <message> [items]...

FLAGS:
    -c, --cancel    Makes the prompt cancellable with 'Esc' or 'q'
    -h, --help      Prints help information
    -i, --index     Returns index of the selected item instead of item itself

OPTIONS:
    -m, --message <message>      Message for the prompt
    -s, --selected <selected>    Specify number of the item that will be selected by default

ARGS:
    <items>...    Items that can be selected

Multi Select Prompt

Prompt that allows the user to select multiple items from a list of options

Enquirer Multi Select Prompt

Usage

enquirer-multi-select 0.5.1
Prompt that allows the user to select multiple items from a list of options

USAGE:
    enquirer multi-select [FLAGS] [OPTIONS] --message <message> [--] [items]...

FLAGS:
    -c, --cancel       Makes the prompt cancellable with 'Esc' or 'q'
    -h, --help         Prints help information
    -i, --index        Returns index of the selected items instead of items itself
        --no-inline    Do not print the selected items on the prompt line
    -d, --default      Makes the prompt return default values as given if --cancel option is present

OPTIONS:
    -m, --message <message>         Message for the prompt
    -s, --selected <selected>...    Specify numbers of items that will be selected by default

ARGS:
    <items>...    Items that can be selected

Sort Prompt

Prompt that allows the user to sort items in a list

Enquirer Sort Prompt

Usage

enquirer-sort 0.5.1
Prompt that allows the user to sort items in a list

USAGE:
    enquirer sort [FLAGS] --message <message> [items]...

FLAGS:
    -c, --cancel       Makes the prompt cancellable with 'Esc' or 'q'
    -h, --help         Prints help information
    -i, --index        Returns index of the sorted items instead of items itself
        --no-inline    Do not print the sorted items on the prompt line
    -d, --default      Makes the prompt return default order as given if --cancel option is present

OPTIONS:
    -m, --message <message>    Message for the prompt

ARGS:
    <items>...    Items that can be sorted

About

Roadmap

Dialoguer issues

  • Select and Multi-Select prompts cursors are after the items list while waiting for user. Maybe change them to be on prompt line.

Changelog

Please see CHANGELOG.md.

License

MIT/X11

Bug Reports

Report here.

Creator

Pavan Kumar Sunkara ([email protected])

Follow me on github, twitter

enquirer's People

Contributors

animeshz avatar brandonkal avatar jensim avatar pksunkara avatar

Watchers

 avatar

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.