cli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Completer = func(document prompt.Document) (suggests []prompt.Suggest) {

	command := document.GetWordBeforeCursor()
	text := document.Text

	if strings.HasPrefix(text, "run ") {
		for _, plan := range Config.Plans {
			suggests = append(suggests, prompt.Suggest{Text: plan.Name, Description: plan.Description})
			sort.Slice(suggests, func(i, j int) bool {
				x := strings.Compare(suggests[i].Text, suggests[j].Text)
				return x < 0
			})
		}
		return prompt.FilterFuzzy(suggests, command, true)
	}

	return prompt.FilterHasPrefix(baseSuggests, command, true)
}

Completer determines the suggestions shown to the user

View Source
var Config model.Config

Config represents the content of the yaml file used to define what this app is capable of doing

View Source
var Executor = func(command string) {

	if strings.HasPrefix(command, "run ") {

		planName := command[len("run "):]
		if plan, ok := Config.Plans[planName]; ok {
			executePlan(plan)
			return
		}
		fmt.Printf("Plan %s not found\n", planName)
	}

	if function, ok := baseFunctions[command]; ok {
		function()
	} else {
		fmt.Println("Command not found!")
	}
}

Executor determines which what to do with the given command

Functions

func ExtractPlans

func ExtractPlans(filePath string) (plans map[string]model.Plan, err error)

ExtractPlans takes the location of the yaml file and delegats it's content to the method reading the content and extracting the plans.

func InitializePlans

func InitializePlans() (err error)

InitializePlans creates the global config instance that creates the plans definitions

Can also be used to update the available plans.

func Start

func Start()

Start creates the prompt instance and runs it

Types

This section is empty.

Jump to

Keyboard shortcuts

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