input

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package input contains helpers to use a text editor as an input for various field of a bug

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFile

func FromFile(fileName string) (string, error)

FromFile loads and returns the contents of a given file. If - is passed through, much like git, it will read from stdin. This can be piped data, unless there is a tty in which case the user will be prompted to enter a message.

func IsURL

func IsURL(name string, value string) (string, error)

IsURL is a validator checking that the value is a fully formed URL

func LaunchEditor

func LaunchEditor(repo repository.RepoCommonStorage, fileName string) (string, error)

LaunchEditor launches the default editor configured for the given repo. This method blocks until the editor command has returned.

The specified filename should be a temporary file and provided as a relative path from the repo (e.g. "FILENAME" will be converted to "[<reporoot>/].git/git-bug/FILENAME"). This file will be deleted after the editor is closed and its contents have been read.

This method returns the text that was read from the temporary file, or an error if any step in the process failed.

func LaunchEditorWithTemplate

func LaunchEditorWithTemplate(repo repository.RepoCommonStorage, fileName string, template string) (string, error)

LaunchEditorWithTemplate will launch an editor as LaunchEditor do, but with a provided template.

func Prompt

func Prompt(prompt, name string, validators ...PromptValidator) (string, error)

Prompt is a simple text input.

func PromptChoice

func PromptChoice(prompt string, choices []string) (int, error)

PromptChoice is a prompt giving possible choices Return the index starting at zero of the choice selected.

func PromptCredential

func PromptCredential(target, name string, credentials []auth.Credential, choices []string) (auth.Credential, int, error)

func PromptDefault

func PromptDefault(prompt, name, preValue string, validators ...PromptValidator) (string, error)

PromptDefault is a simple text input with a default value.

func PromptPassword

func PromptPassword(prompt, name string, validators ...PromptValidator) (string, error)

PromptPassword is a specialized text input that doesn't display the characters entered.

func PromptURLWithRemote

func PromptURLWithRemote(prompt, name string, validRemotes []string, validators ...PromptValidator) (string, error)

func Required

func Required(name string, value string) (string, error)

Required is a validator preventing a "" value

Types

type PromptValidator

type PromptValidator func(name string, value string) (complaint string, err error)

PromptValidator is a validator for a user entry If complaint is "", value is considered valid, otherwise it's the error reported to the user If err != nil, a terminal error happened

Jump to

Keyboard shortcuts

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