cmd

package
v2.6.20 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 34 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Timeout is the default timeout used for most commands.
	Timeout = time.Minute * 10
	// PushTimeout is the command timeout used when pushing bucket changes.
	PushTimeout = time.Hour * 24
	// PullTimeout is the command timeout used when pulling bucket changes.
	PullTimeout = time.Hour * 24
	// ArchiveWatchTimeout is the command timeout used when watching archive status messages.
	ArchiveWatchTimeout = time.Hour * 12

	// Bold is a styler used to make the output text bold.
	Bold = promptui.Styler(promptui.FGBold)

	// Repo organization/repo where client releases are published
	Repo = "textileio/textile"
)

Functions

func AddrFromStr

func AddrFromStr(str string) ma.Multiaddr

AddrFromStr returns a multiaddress from the string.

func BindFlags

func BindFlags(v *viper.Viper, root *cobra.Command, flags map[string]Flag) error

BindFlags binds the flags to the viper config values.

func End

func End(format string, args ...interface{})

func ErrCheck

func ErrCheck(err error, args ...interface{})

func Error

func Error(err error, args ...interface{})

func ExpandConfigVars

func ExpandConfigVars(v *viper.Viper, flags map[string]Flag)

ExpandConfigVars evaluates the viper config file's expressions.

func Fatal

func Fatal(err error, args ...interface{})

func FindConfigFile

func FindConfigFile(conf *Config, pth string) bool

FindConfigFile searches up the path for a config file. True is returned is a config file was found and successfully loaded.

func GetFlagOrEnvValue

func GetFlagOrEnvValue(c *cobra.Command, k, envPre string) (v string)

GetFlagOrEnvValue first load a value for the key from the command flags. If no value was found, the value for the corresponding env variable is returned.

func GetThreadType

func GetThreadType(isDB bool) string

GetThreadType returns a string representation of the type of a thread.

func HandleInterrupt added in v2.1.4

func HandleInterrupt(stop func())

func InitConfig

func InitConfig(conf *Config) func()

InitConfig returns a function that can be used to search for and load a config file.

func InitConfigCmd

func InitConfigCmd(rootCmd *cobra.Command, v *viper.Viper, dir string)

InitConfigCmd adds a config generator command to the root command. The command will write the config file to dir.

func IsConnectionError

func IsConnectionError(err error) bool

IsConnectionError returns true if the error is related to a dropped connection.

func JSON added in v2.5.0

func JSON(data interface{})

func Message

func Message(format string, args ...interface{})

func RenderTable

func RenderTable(header []string, data [][]string)

func RenderTableWithoutNewLines added in v2.6.4

func RenderTableWithoutNewLines(header []string, data [][]string)

func SetupDefaultLoggingConfig added in v2.5.0

func SetupDefaultLoggingConfig(file string) error

func Success

func Success(format string, args ...interface{})

func Warn

func Warn(format string, args ...interface{})

func Watch

func Watch(ctx context.Context, watchFunc WatchFunc, reconnectInterval time.Duration) (<-chan WatchState, error)

Watch calls watchFunc until it returns an error. Normally, watchFunc would block while doing work that can fail, e.g., the local network goes offline. If watchFunc return an error, it will be called again at the given interval so long as the returned error is non-fatal. Returns a channel of watch connectivity states. Cancel context to stop watching.

func WriteConfig

func WriteConfig(c *cobra.Command, v *viper.Viper, name string)

WriteConfig writes the viper config based on the command.

func WriteConfigToHome added in v2.1.4

func WriteConfigToHome(config *Config)

WriteConfigToHome writes config to the home directory.

Types

type Clients

type Clients struct {
	Buckets    *bc.Client
	Threads    *tc.Client
	Hub        *hc.Client
	Users      *uc.Client
	Filecoin   *fc.Client
	MinerIndex *mi.Client
}

Clients wraps all the possible hubd/buckd clients.

func NewClients

func NewClients(hubTarget string, isHub bool, minerIndexTarget string) *Clients

NewClients returns a new clients object pointing to the target address. If isHub is true, the hub's admin and user clients are also created.

func (*Clients) Close

func (c *Clients) Close()

Close closes all the clients.

func (*Clients) ListThreads

func (c *Clients) ListThreads(ctx context.Context, dbsOnly bool) []Thread

ListThreads returns a list of threads for the context. In a hub context, this will only list threads that the context has access to. dbsOnly filters threads that do not belong to a database.

func (*Clients) SelectThread

func (c *Clients) SelectThread(ctx context.Context, label, successMsg string, dbsOnly bool) Thread

SelectThread presents the caller with a choice of threads.

type ConfConfig

type ConfConfig struct {
	Dir       string // Config directory base name
	Name      string // Name of the mailbox config file
	Type      string // Type is the type of config file (yaml/json)
	EnvPrefix string // A prefix that will be expected on env vars
}

ConfConfig is used to generate new messages configs.

func (ConfConfig) NewConfig

func (cc ConfConfig) NewConfig(pth string, flags map[string]Flag, global bool) (c *Config, fileExists bool, err error)

NewConfig uses values from ConfConfig to contruct a new config.

type Config

type Config struct {
	Viper  *viper.Viper
	File   string
	Dir    string
	Name   string
	Flags  map[string]Flag
	EnvPre string
	Global bool
}

Config describes a command config params and file info.

type ConnectionState

type ConnectionState int

ConnectionState indicates an online/offline state.

const (
	// Offline indicates the remote is currently not reachable.
	Offline ConnectionState = iota
	// Online indicates a connection with the remote has been established.
	Online
)

func (ConnectionState) String

func (cs ConnectionState) String() string

type Flag

type Flag struct {
	Key      string
	DefValue interface{}
}

Flag describes a command flag.

type Thread

type Thread struct {
	ID    thread.ID `json:"id"`
	Label string    `json:"label"`
	Name  string    `json:"name"`
	Type  string    `json:"type"`
}

Thread wraps details about a thread.

type WatchFunc

type WatchFunc func(context.Context) (<-chan WatchState, error)

WatchFunc is a function wrapper for a function used by Watch.

type WatchState

type WatchState struct {
	// State of the watch connection (online/offline).
	State ConnectionState
	// Err returned by the watch operation.
	Err error
	// Aborted indicates whether or not the associated error aborted the watch.
	// (Connectivity related errors do not abort the watch.)
	Aborted bool
}

WatchState is used to inform Watch callers about the connection state.

Directories

Path Synopsis
cli
hub
cli

Jump to

Keyboard shortcuts

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