prompts

package
v1.5.3-rc.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 24 Imported by: 4

Documentation

Overview

Copyright (C) 2022, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2022, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

View Source
const (
	Yes = "Yes"
	No  = "No"

	Add        = "Add"
	Del        = "Delete"
	Preview    = "Preview"
	MoreInfo   = "More Info"
	Done       = "Done"
	Cancel     = "Cancel"
	LessThanEq = "Less Than Or Eq"
	MoreThanEq = "More Than Or Eq"
	MoreThan   = "More Than"
	NotEq      = "Not Eq"
)

Variables

This section is empty.

Functions

func CaptureBoolFlag added in v1.5.0

func CaptureBoolFlag(
	prompt Prompter,
	cmd *cobra.Command,
	flagName string,
	flagValue bool,
	promptMsg string,
) (bool, error)

func CaptureListDecision added in v0.2.3

func CaptureListDecision[T comparable](

	prompter Prompter,

	prompt string,

	capture func(prompt string) (T, error),

	capturePrompt string,

	label string,

	info string,
) ([]T, bool, error)

CaptureListDecision runs a for loop and continuously asks the user for a specific input (currently only `CapturePChainAddress` and `CaptureAddress` is supported) until the user cancels or chooses `Done`. It does also offer an optional `info` to print (if provided) and a preview. Items can also be removed.

func CheckSubnetAuthKeys added in v1.0.0

func CheckSubnetAuthKeys(walletKeys []string, subnetAuthKeys []string, controlKeys []string, threshold uint32) error

check subnet authorization criteria: - [subnetAuthKeys] satisfy subnet's [threshold] - [subnetAuthKeys] is a subset of subnet's [controlKeys]

func GetFujiKeyOrLedger added in v1.0.0

func GetFujiKeyOrLedger(prompt Prompter, goal string, keyDir string) (bool, string, error)

func GetSubnetAuthKeys added in v1.0.0

func GetSubnetAuthKeys(prompt Prompter, walletKeys []string, controlKeys []string, threshold uint32) ([]string, error)

get subnet authorization keys from the user, as a subset of the subnet's [controlKeys] with a len equal to the subnet's [threshold]

func RequestURL added in v1.3.1

func RequestURL(url string) (*http.Response, error)

func ValidateHexa added in v1.3.3

func ValidateHexa(input string) error

func ValidateRepoBranch added in v1.3.1

func ValidateRepoBranch(repo string, branch string) error

func ValidateRepoFile added in v1.3.1

func ValidateRepoFile(repo string, branch string, file string) error

func ValidateURL added in v1.3.1

func ValidateURL(url string) error

Types

type Comparator added in v1.2.0

type Comparator struct {
	Label string // Label that identifies reference value
	Type  string // Less Than Eq or More than Eq
	Value uint64 // Value to Compare To
}

func (*Comparator) Validate added in v1.2.0

func (comparator *Comparator) Validate(val uint64) error

type Prompter added in v0.2.0

type Prompter interface {
	CapturePositiveBigInt(promptStr string) (*big.Int, error)
	CaptureAddress(promptStr string) (common.Address, error)
	CaptureNewFilepath(promptStr string) (string, error)
	CaptureExistingFilepath(promptStr string) (string, error)
	CaptureYesNo(promptStr string) (bool, error)
	CaptureNoYes(promptStr string) (bool, error)
	CaptureList(promptStr string, options []string) (string, error)
	CaptureListWithSize(promptStr string, options []string, size int) (string, error)
	CaptureString(promptStr string) (string, error)
	CaptureValidatedString(promptStr string, validator func(string) error) (string, error)
	CaptureURL(promptStr string, validateConnection bool) (string, error)
	CaptureRepoBranch(promptStr string, repo string) (string, error)
	CaptureRepoFile(promptStr string, repo string, branch string) (string, error)
	CaptureGitURL(promptStr string) (*url.URL, error)
	CaptureStringAllowEmpty(promptStr string) (string, error)
	CaptureEmail(promptStr string) (string, error)
	CaptureIndex(promptStr string, options []any) (int, error)
	CaptureVersion(promptStr string) (string, error)
	CaptureFujiDuration(promptStr string) (time.Duration, error)
	CaptureMainnetDuration(promptStr string) (time.Duration, error)
	CaptureDate(promptStr string) (time.Time, error)
	CaptureNodeID(promptStr string) (ids.NodeID, error)
	CaptureID(promptStr string) (ids.ID, error)
	CaptureWeight(promptStr string) (uint64, error)
	CapturePositiveInt(promptStr string, comparators []Comparator) (int, error)
	CaptureInt(promptStr string) (int, error)
	CaptureUint32(promptStr string) (uint32, error)
	CaptureUint64(promptStr string) (uint64, error)
	CaptureFloat(promptStr string, validator func(float64) error) (float64, error)
	CaptureUint64Compare(promptStr string, comparators []Comparator) (uint64, error)
	CapturePChainAddress(promptStr string, network models.Network) (string, error)
	CaptureXChainAddress(promptStr string, network models.Network) (string, error)
	CaptureFutureDate(promptStr string, minDate time.Time) (time.Time, error)
	ChooseKeyOrLedger(goal string) (bool, error)
}

func NewPrompter added in v0.2.0

func NewPrompter() Prompter

NewProcessChecker creates a new process checker which can respond if the server is running

Jump to

Keyboard shortcuts

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