cmd

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 23 Imported by: 0

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)
)

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 added in v1.0.13

func ErrCheck(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 added in v1.0.13

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 added in v1.0.13

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 added in v1.0.4

func GetThreadType(isDB bool) string

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

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 added in v1.0.4

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 Message

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

func RenderTable

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

func Success

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

func Warn added in v1.0.2

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

func WriteConfig added in v1.0.4

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

WriteConfig writes the viper config with name.

Types

type Clients added in v1.0.4

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

Clients wraps all the possible hubd/buckd clients.

func NewClients added in v1.0.4

func NewClients(target string, isHub bool) *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 added in v1.0.4

func (c *Clients) Close()

Close closes all the clients.

func (*Clients) ListThreads added in v1.0.4

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 added in v1.0.4

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

SelectThread presents the caller with a choice of threads.

type Config added in v1.0.4

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 Flag

type Flag struct {
	Key      string
	DefValue interface{}
}

Flaf describes a command flag.

type Thread added in v1.0.4

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.

Directories

Path Synopsis
cli
hub
cli

Jump to

Keyboard shortcuts

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