Documentation
¶
Overview ¶
Package userinput provides functions to obtain interactive user input for command line tools.
Index ¶
- func DropCommentLines(text string) string
- func GetDeviceSpecs(initial *inventory.DeviceUnderTest, helpText string, promptFunc PromptFunc, ...) (*inventory.DeviceUnderTest, error)
- func GetMCSVSpecs(specsFile string) ([]*inventory.DeviceUnderTest, error)
- func ValidBug(bug string) bool
- type PromptFunc
- type SpecsValidationFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropCommentLines ¶
DropCommentLines drops lines from text that are comment lines, commented using commentLines().
func GetDeviceSpecs ¶
func GetDeviceSpecs(initial *inventory.DeviceUnderTest, helpText string, promptFunc PromptFunc, validateFunc SpecsValidationFunc) (*inventory.DeviceUnderTest, error)
GetDeviceSpecs interactively obtains inventory.DeviceUnderTest from the user.
This function provides the user with initial specs, some help text and an example of a complete device spec. User's updated specs are parsed and any errors are reported back to the user, allowing the user to fix the errors. promptFunc is used to prompt the user on parsing errors, to give them a choice to continue or abort the input session.
Callers may pass a non-nil validateFunc to validate the user's updated specs. validateFunc is called within the userinput iteration loop described above, and errors are reported back to error in the same way as parsing errors.
This function returns upon successful parsing of the user input, or upon user initiated abort.
func GetMCSVSpecs ¶
func GetMCSVSpecs(specsFile string) ([]*inventory.DeviceUnderTest, error)
GetMCSVSpecs get a sequence of DeviceUnderTests in the MCSV format from the specified file.
Types ¶
type PromptFunc ¶
PromptFunc obtains consent from the user for the given request string.
This function is used to provide the user some context through the provided string and then obtain a yes/no answer from the user.
type SpecsValidationFunc ¶
type SpecsValidationFunc func(*inventory.DeviceUnderTest) error
SpecsValidationFunc checks provided device specs for error.
This function returns nil if provided specs are valid.