cobraprompt

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 5 Imported by: 0

README

Cobra-Prompt

Connect cobra and go-prompt

https://github.com/c-bata/go-prompt

https://github.com/spf13/cobra

Example

This example uses glide.

cd example
glide install
go build -o cobra-prompt
./cobra-prompt

Documentation

Index

Constants

View Source
const CALLBACK_ANNOTATION = "cobra-prompt"

CALLBACK_ANNOTATION

Variables

This section is empty.

Functions

This section is empty.

Types

type CobraPrompt

type CobraPrompt struct {
	// RootCmd is the start point, all its sub commands and flags will be available as suggestions
	RootCmd *cobra.Command

	// GoPromptOptions is for customize go-prompt
	// see https://github.com/c-bata/go-prompt/blob/master/option.go
	GoPromptOptions []prompt.Option

	// DynamicSuggestionsFunc will be executed if an command has CALLBACK_ANNOTATION as an annotation. If it's included
	// the value will be provided to the DynamicSuggestionsFunc function.
	DynamicSuggestionsFunc func(annotation string, document prompt.Document) []prompt.Suggest

	// ResetFlagsFlag will add a new persistent flag to RootCmd. This flags can be used to turn off flags value reset
	ResetFlagsFlag bool
}

CobraPrompt requires RootCmd to run

func (CobraPrompt) Run

func (co CobraPrompt) Run()

Run will automatically generate suggestions for all cobra commands and flags defined by RootCmd and execute the selected commands. Run will also reset all given flags by default, see ResetFlagsFlag

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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