Documentation ¶
Index ¶
- Variables
- func AddrFromStr(str string) ma.Multiaddr
- func BindFlags(v *viper.Viper, root *cobra.Command, flags map[string]Flag) error
- func End(format string, args ...interface{})
- func ErrCheck(err error, args ...interface{})
- func Error(err error, args ...interface{})
- func ExpandConfigVars(v *viper.Viper, flags map[string]Flag)
- func Fatal(err error, args ...interface{})
- func FindConfigFile(conf *Config, pth string) bool
- func GetFlagOrEnvValue(c *cobra.Command, k, envPre string) (v string)
- func GetThreadType(isDB bool) string
- func HandleInterrupt(stop func())
- func InitConfig(conf *Config) func()
- func InitConfigCmd(rootCmd *cobra.Command, v *viper.Viper, dir string)
- func IsConnectionError(err error) bool
- func Message(format string, args ...interface{})
- func RenderTable(header []string, data [][]string)
- func Success(format string, args ...interface{})
- func Warn(format string, args ...interface{})
- func Watch(ctx context.Context, watchFunc WatchFunc, reconnectInterval time.Duration) (<-chan WatchState, error)
- func WriteConfig(c *cobra.Command, v *viper.Viper, name string)
- func WriteConfigToHome(config *Config)
- type Clients
- type ConfConfig
- type Config
- type ConnectionState
- type Flag
- type Thread
- type WatchFunc
- type WatchState
Constants ¶
This section is empty.
Variables ¶
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 ¶
AddrFromStr returns a multiaddress from the string.
func ExpandConfigVars ¶
ExpandConfigVars evaluates the viper config file's expressions.
func FindConfigFile ¶
FindConfigFile searches up the path for a config file. True is returned is a config file was found and successfully loaded.
func GetFlagOrEnvValue ¶
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 ¶
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 ¶
InitConfigCmd adds a config generator command to the root command. The command will write the config file to dir.
func IsConnectionError ¶
IsConnectionError returns true if the error is related to a dropped connection.
func RenderTable ¶
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 ¶
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 Pow *pc.Client }
Clients wraps all the possible hubd/buckd clients.
func NewClients ¶
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) ListThreads ¶
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.
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.
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 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 // Error 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.