ask

package module
v0.0.0-...-d8472e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2017 License: MIT Imports: 8 Imported by: 0

README

go-ask

Just a few functions for helping questions and user's input.

go get it as github.com/b4b4r07/go-ask, import it as "github.com/b4b4r07/go-ask", use it as ask.

See godoc for complete documentation.

Example

$ go get github.com/b4b4r07/go-ask
package main

import (
	"fmt"

	"github.com/b4b4r07/go-ask"
)

func main() {
	if ask.NewQ().Confirm("Do you want to remove this?") {
		fmt.Println("done")
	}
}

License

MIT

Author

b4b4r07

Documentation

Overview

Package ask provides some simple question methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Password

func Password(s string) (input []byte, err error)

Password reads password without echo

Types

type Q

type Q struct {
	// Prompt is the format of the question text
	Prompt string
	// Retry indicates the number of repetitions of Y/N
	Retry int
	// Newline returns true if allow empty input (e.g. newline)
	Newline bool
	// contains filtered or unexported fields
}

Q is question object

func NewQ

func NewQ() *Q

NewQ returns new Q

func (*Q) Confirm

func (q *Q) Confirm(s string) bool

Confirm makes a simple closed question

func (*Q) Confirmf

func (q *Q) Confirmf(qfmt string, a ...interface{}) bool

Confirmf is Confirm with a trailing "f" wrap fmt.Sprintf

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL