commands

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package commands contains any general setup/helpers valid for all subcommands

Index

Constants

View Source
const (
	ChainFlag = "chain-id"
	NodeFlag  = "node"
)
View Source
const (
	SeedFlag      = "seed"
	HashFlag      = "valhash"
	GenesisFlag   = "genesis"
	FlagTrustNode = "trust-node"

	ConfigFile = "config.toml"
)

nolint

Variables

View Source
var CommitHash = ""

CommitHash should be filled by linker flags

View Source
var InitCmd = &cobra.Command{
	Use:   "init",
	Short: "Initialize the light client for a new chain",
	RunE:  runInit,
}

InitCmd will initialize the basecli store

View Source
var ResetCmd = &cobra.Command{
	Use:   "reset_all",
	Short: "DANGEROUS: Wipe out all client data, including keys",
	RunE:  runResetAll,
}
View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "Show version info",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("v%s %s\n", version.Version, CommitHash)
	},
}

VersionCmd - command to show the application version

Functions

func AddBasicFlags

func AddBasicFlags(cmd *cobra.Command)

AddBasicFlags adds --node and --chain-id, which we need for everything

func GetCertifier

func GetCertifier() (*certifiers.InquiringCertifier, error)

GetCertifier constructs a dynamic certifier from the config info

func GetChainID

func GetChainID() string

GetChainID reads ChainID from the flags

func GetNode

func GetNode() rpcclient.Client

GetNode prepares a simple rpc.Client from the flags

func GetOneArg

func GetOneArg(args []string, argname string) (string, error)

GetOneArg makes sure there is exactly one positional argument

func GetProviders

func GetProviders() (trusted certifiers.Provider, source certifiers.Provider)

GetProviders creates a trusted (local) seed provider and a remote provider based on configuration.

func GetSourceProvider

func GetSourceProvider() certifiers.Provider

GetSourceProvider returns a provider pointing to an rpc handler

func GetTrustedProvider

func GetTrustedProvider() certifiers.Provider

GetTrustedProvider returns a reference to a local store with cache

func ParseActor

func ParseActor(input string) (res sdk.Actor, err error)

ParseActor parses an address of form: [<chain>:][<app>:]<hex address> into a sdk.Actor. If app is not specified or "", then assume auth.NameSigs

func ParseActors

func ParseActors(key string) (signers []sdk.Actor, err error)

ParseActors takes a comma-separated list of actors and parses them into a slice

func ParseHexFlag

func ParseHexFlag(flag string) ([]byte, error)

ParseHexFlag takes a flag name and parses the viper contents as hex

func WasInited

func WasInited(root string) (bool, error)

WasInited returns true if a basecoin was previously initialized in this directory. Important to ensure proper behavior.

Returns error if we have filesystem errors

Types

type Config

type Config struct {
	Chain    string `toml:"chain-id,omitempty"`
	Node     string `toml:"node,omitempty"`
	Output   string `toml:"output,omitempty"`
	Encoding string `toml:"encoding,omitempty"`
}

type Runable

type Runable func(cmd *cobra.Command, args []string) error

func RequireInit

func RequireInit(run Runable) Runable

Any commands that require and init'ed basecoin directory should wrap their RunE command with RequireInit to make sure that the client is initialized.

This cannot be called during PersistentPreRun, as they are called from the most specific command first, and root last, and the root command sets up viper, which is needed to find the home dir.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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