MCPcopy
hub / github.com/manifoldco/promptui

github.com/manifoldco/promptui @v0.9.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.9.0 ↗
100 symbols 314 edges 29 files 60 documented · 60%
README

promptui

Interactive prompt for command-line applications.

We built Promptui because we wanted to make it easy and fun to explore cloud services with manifold cli.

Code of Conduct | Contribution Guidelines

GitHub release GoDoc Travis Go Report Card License

Overview

promptui

Promptui is a library providing a simple interface to create command-line prompts for go. It can be easily integrated into spf13/cobra, urfave/cli or any cli go application.

Promptui has two main input modes:

  • Prompt provides a single line for user input. Prompt supports optional live validation, confirmation and masking the input.

  • Select provides a list of options to choose from. Select supports pagination, search, detailed view and custom templates.

For a full list of options check GoDoc.

Basic Usage

Prompt

package main

import (
    "errors"
    "fmt"
    "strconv"

    "github.com/manifoldco/promptui"
)

func main() {
    validate := func(input string) error {
        _, err := strconv.ParseFloat(input, 64)
        if err != nil {
            return errors.New("Invalid number")
        }
        return nil
    }

    prompt := promptui.Prompt{
        Label:    "Number",
        Validate: validate,
    }

    result, err := prompt.Run()

    if err != nil {
        fmt.Printf("Prompt failed %v\n", err)
        return
    }

    fmt.Printf("You choose %q\n", result)
}

Select

package main

import (
    "fmt"

    "github.com/manifoldco/promptui"
)

func main() {
    prompt := promptui.Select{
        Label: "Select Day",
        Items: []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
            "Saturday", "Sunday"},
    }

    _, result, err := prompt.Run()

    if err != nil {
        fmt.Printf("Prompt failed %v\n", err)
        return
    }

    fmt.Printf("You choose %q\n", result)
}

More Examples

See full list of examples

Extension points exported contracts — how you extend this code

ValidateFunc (FuncType)
ValidateFunc is a placeholder type for any validation functions that validates a given input. It should return a Validat
promptui.go
Pointer (FuncType)
Pointer is A specific type that translates a given set of runes into a given set of runes pointed at by the cursor.
cursor.go
Searcher (FuncType)
Searcher is a base function signature that is used inside select when activating the search mode. If defined, it is call
list/list.go

Core symbols most depended-on inside this repo

Styler
called by 36
codes.go
Format
called by 30
cursor.go
Run
called by 29
prompt.go
render
called by 21
select.go
Write
called by 21
screenbuf/screenbuf.go
Get
called by 11
cursor.go
Reset
called by 9
screenbuf/screenbuf.go
Flush
called by 9
screenbuf/screenbuf.go

Shape

Method 44
Function 36
Struct 16
FuncType 3
TypeAlias 1

Languages

Go100%

Modules by API surface

cursor.go21 symbols
list/list.go17 symbols
select.go16 symbols
screenbuf/screenbuf.go7 symbols
list/list_test.go7 symbols
prompt.go4 symbols
codes.go4 symbols
select_test.go3 symbols
example_select_test.go2 symbols
example_main_test.go2 symbols
cursor_test.go2 symbols
_examples/custom_select/main.go2 symbols

Dependencies from manifests, versioned

github.com/chzyer/logexv1.1.10 · 1×
github.com/chzyer/readlinev0.0.0-2018060313265 · 1×
github.com/chzyer/testv0.0.0-2018021303581 · 1×
golang.org/x/sysv0.0.0-2018112214520 · 1×

For agents

$ claude mcp add promptui \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact