prompt

package
v0.0.0-...-dd95ca6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package prompt contains logic for prompts and user interactions with the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnterDirectory

func EnterDirectory() (string, error)

EnterDirectory prompts the user to enter the name of the directory they want to save the created template in.

func EnterFileName

func EnterFileName() (string, error)

EnterFileName prompts the user to enter the name of the file they are going to save a template as, and returns a sanitised.

func SelectDirectory

func SelectDirectory(parent string) (string, error)

SelectDirectory prompts the user to select a sub driectory in the provided parent. If the parent directory does not have any subdirectories this will error.

func SelectExistingFile

func SelectExistingFile(searchDir string) (string, error)

SelectExistingFile prompt the user to select a file and returns the full path of the selected file.

func SelectTemplate

func SelectTemplate(templates config.Templates) (config.Template, error)

SelectTemplate prompts the user to select a template from the ones defined in config.

Types

type SelectorFunc

type SelectorFunc func(config.Templates) (config.Template, error)

SelectorFunc is the type def for the selector func used in the TemplateSelector struct.

type TemplateSelector

type TemplateSelector struct {
	SelectFunc SelectorFunc
}

TemplateSelector is a utility struct to enable mocking of calls to the survey prompt for easier testability.

func NewTemplateSelector

func NewTemplateSelector() TemplateSelector

NewTemplateSelector creates a new instance of the TemplateSelector struct.

func (TemplateSelector) SelectTemplateWithSubTemplates

func (t TemplateSelector) SelectTemplateWithSubTemplates(
	templates config.Templates,
	selectedTemplates []config.Template,
) ([]config.Template, error)

SelectTemplateWithSubTemplates is a recursive function to select template with nested sub templates and return them in a slice so they can all be referenced and the fully nested path to a document can be worked out.

Jump to

Keyboard shortcuts

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