config

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConfigDir is the directory to store config file
	ConfigDir string
	// DefaultConfigFile is the default config file name
	DefaultConfigFile string
)

Directories

View Source
var (
	// ErrConfigNotMatch indicates error for no config matches
	ErrConfigNotMatch = fmt.Errorf("no matching config")
	// ErrEmptyEndpoint indicates error for empty endpoint
	ErrEmptyEndpoint = fmt.Errorf("no endpoint has been set")
	// ErrConfigDefaultAccountNotSet indicates an error for the default account not being set
	ErrConfigDefaultAccountNotSet = fmt.Errorf("default account not set")
)

Error strings

View Source
var (
	// ReadConfig represents the current config read from local
	ReadConfig Config
	// Insecure represents the insecure connect option of grpc dial, default is false
	Insecure = false
	// UILanguage represents the language of ioctl user interface, default is 0 representing English
	UILanguage Language
)
View Source
var ConfigCmd = &cobra.Command{
	Use:   "config",
	Short: "Get, set, or reset configuration for ioctl",
}

ConfigCmd represents the config command

Functions

func Get

func Get(arg string) error

Get gets config variable

func GetAddressOrAlias

func GetAddressOrAlias(in string) (address string, err error)

GetAddressOrAlias gets address from args or context

func GetContextAddressOrAlias

func GetContextAddressOrAlias() (string, error)

GetContextAddressOrAlias gets current context

func TranslateInLang

func TranslateInLang(translations map[Language]string, lang Language) string

TranslateInLang returns translation in selected language

Types

type Config

type Config struct {
	Wallet           string            `json:"wallet" yaml:"wallet"`
	Endpoint         string            `json:"endpoint" yaml:"endpoint"`
	SecureConnect    bool              `json:"secureConnect" yaml:"secureConnect"`
	Aliases          map[string]string `json:"aliases" yaml:"aliases"`
	DefaultAccount   Context           `json:"defaultAccount" yaml:"defaultAccount"`
	Explorer         string            `json:"explorer" yaml:"explorer"`
	Language         string            `json:"language" yaml:"language"`
	Nsv2height       uint64            `json:"nsv2height" yaml:"nsv2height"`
	AnalyserEndpoint string            `json:"analyserEndpoint" yaml:"analyserEndpoint"`
	// WsEndpoint w3bstream endpoint
	WsEndpoint string `json:"wsEndpoint" yaml:"wsEndpoint"`
	// IPFSEndpoint ipfs endpoint for uploading
	IPFSEndpoint string `json:"ipfsEndpoint" yaml:"ipfsEndpoint"`
	// IPFSGateway ipfs gateway for resource fetching (with scheme)
	IPFSGateway string `json:"ipfsGateway" yaml:"ipfsGateway"`
	// WsRegisterContract w3bstream project register contract address
	WsRegisterContract string `json:"wsRegisterContract" yaml:"wsRegisterContract"`
}

Config defines the config schema

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig loads config file in yaml format

func (*Config) Lang added in v1.7.1

func (c *Config) Lang() Language

Lang returns the selected language, default is English

func (*Config) String

func (m *Config) String() string

type Context

type Context struct {
	AddressOrAlias string `json:"addressOrAlias" yaml:"addressOrAlias"`
}

Context represents the current context

func (*Context) String

func (m *Context) String() string

type Language

type Language int

Language type used to enumerate supported language of ioctl

const (
	English Language = iota
	Chinese
)

Multi-language support

Jump to

Keyboard shortcuts

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