Documentation ¶
Index ¶
- Constants
- func ArbitraryDataFlagVar(f *pflag.FlagSet, s *[]byte, name string, usage string)
- func ArbitraryDataFlagVarP(f *pflag.FlagSet, s *[]byte, name, shorthand string, usage string)
- func Die(args ...interface{})
- func DieWithError(description string, err error)
- func DieWithExitCode(code int, args ...interface{})
- func EncodingTypeFlagDescription(mask EncodingType) string
- func NetAddressArrayFlagVar(f *pflag.FlagSet, s *[]modules.NetAddress, name string, usage string)
- func NetAddressArrayFlagVarP(f *pflag.FlagSet, s *[]modules.NetAddress, name, shorthand string, ...)
- type ArbitraryDataFlag
- type EncodingType
- type EncodingTypeFlag
- type LockTimeFlag
- type StringLoader
- type StringLoaderFlag
Constants ¶
const ( ExitCodeGeneral = 1 // Not in sysexits.h, but is standard practice. ExitCodeNotFound = 2 ExitCodeCancelled = 3 ExitCodeForbidden = 4 ExitCodeTemporaryError = 5 ExitCodeUsage = 64 // EX_USAGE in sysexits.h )
exit codes inspired by sysexits.h
const ( // DateOnlyLayout allows you to define a timestamp using a date only, // where GMT is assumed as the timezone: DD/MM/YYYY TZN DateOnlyLayout = "02/01/2006 MST" )
Variables ¶
This section is empty.
Functions ¶
func ArbitraryDataFlagVar ¶ added in v1.2.0
ArbitraryDataFlagVar defines a ArbitraryData flag with specified name and usage string. The argument s points to an array of bytes variable in which to store the validated values of the flags. The value of each argument will not try to be separated by comma, each value has to be defined as a separate flag (using the same name).
func ArbitraryDataFlagVarP ¶ added in v1.2.0
ArbitraryDataFlagVarP defines a ArbitraryData flag with specified name, shorthand and usage string. The argument s points to an array of bytes variable in which to store the validated values of the flags. The value of each argument will not try to be separated by comma, each value has to be defined as a separate flag (using the same name or shorthand).
func Die ¶ added in v1.2.0
func Die(args ...interface{})
Die prints its arguments to stderr, then exits the program with the default error code.
func DieWithError ¶ added in v1.2.0
DieWithError exits with an error. if the error is of the type api.ErrorWithStatusCode, its status will be used, otherwise the General exit code will be used
func DieWithExitCode ¶ added in v1.2.0
func DieWithExitCode(code int, args ...interface{})
DieWithExitCode prints its arguments to stderr, then exits the program with the given exit code.
func EncodingTypeFlagDescription ¶ added in v1.0.6
func EncodingTypeFlagDescription(mask EncodingType) string
EncodingTypeFlagDescription returns a description for an encoding type flag, optionally given an encoding type mask (0 means all encoding types are allowed).
func NetAddressArrayFlagVar ¶ added in v1.2.0
NetAddressArrayFlagVar defines a []modules.NetAddress flag with specified name and usage string. The argument s points to a []modules.NetAddress variable in which to store the validated values of the flags. The value of each argument will not try to be separated by comma, each value has to be defined as a separate flag (using the same name).
func NetAddressArrayFlagVarP ¶ added in v1.2.0
func NetAddressArrayFlagVarP(f *pflag.FlagSet, s *[]modules.NetAddress, name, shorthand string, usage string)
NetAddressArrayFlagVarP defines a []modules.NetAddress flag with specified name, shorthand and usage string. The argument s points to a []modules.NetAddress variable in which to store the validated values of the flags. The value of each argument will not try to be separated by comma, each value has to be defined as a separate flag (using the same name or shorthand).
Types ¶
type ArbitraryDataFlag ¶ added in v1.2.0
type ArbitraryDataFlag struct {
// contains filtered or unexported fields
}
ArbitraryDataFlag is used to pass arbitrary data to transactions
func (*ArbitraryDataFlag) Set ¶ added in v1.2.0
func (flag *ArbitraryDataFlag) Set(str string) error
Set implements pflag.Value.Set
func (*ArbitraryDataFlag) String ¶ added in v1.2.0
func (flag *ArbitraryDataFlag) String() string
String implements pflag.Value.String
func (*ArbitraryDataFlag) Type ¶ added in v1.2.0
func (flag *ArbitraryDataFlag) Type() string
Type implements pflag.Value.Type
type EncodingType ¶ added in v1.0.6
type EncodingType uint8
EncodingType defines an enum, to represent all encoding options.
const ( // EncodingTypeHuman encodes the output in a human-optimized format, // a format which can chance at any point and should be used only // for human readers. EncodingTypeHuman EncodingType = 1 << iota // EncodingTypeJSON encodes the output as a minified JSON string, // and has a format which is promised to be backwards-compatible, // to be used for automation purposes. EncodingTypeJSON // EncodingTypeHex encodes the output using the internal binary encoder, // and encoding that binary output using the std hex encoder, // resulting in a hex-encoded string. EncodingTypeHex )
type EncodingTypeFlag ¶ added in v1.0.6
type EncodingTypeFlag struct {
// contains filtered or unexported fields
}
EncodingTypeFlag is a utility flag which can be used to expose an encoding type as an optionally masked flag.
func NewEncodingTypeFlag ¶ added in v1.0.6
func NewEncodingTypeFlag(def EncodingType, ref *EncodingType, mask EncodingType) EncodingTypeFlag
NewEncodingTypeFlag returns a new EncodingTypeFlag, referencing an encoding type value, defaulting it to a default value, and optionally allowing you to mask
func (EncodingTypeFlag) Set ¶ added in v1.0.6
func (e EncodingTypeFlag) Set(s string) error
Set implements pflag.Value.Set, only the options as defind by the mask are allowed, and the given string is interpreted in a case insensitive manner.
func (EncodingTypeFlag) String ¶ added in v1.0.6
func (e EncodingTypeFlag) String() string
String implements pflag.Value.String, returning the selected enum option as a lower-case string.
func (EncodingTypeFlag) Type ¶ added in v1.0.6
func (e EncodingTypeFlag) Type() string
Type implements pflag.Value.Type
type LockTimeFlag ¶
type LockTimeFlag struct {
// contains filtered or unexported fields
}
LockTimeFlag defines LockTime as a flag, as to give the user several ways to define the lock time, such that for example the user isn't required to define it in unix epoch time.
func (*LockTimeFlag) LockTime ¶
func (f *LockTimeFlag) LockTime() uint64
LockTime returns the internal lock time of this LockTime flag
func (*LockTimeFlag) Set ¶
func (f *LockTimeFlag) Set(s string) error
Set implements pflag.Value.Set, which parses the given string either as a timestamp in DateOnlyLayout or RFC822 layout, a duration or as an uint64.
func (*LockTimeFlag) String ¶
func (f *LockTimeFlag) String() string
String implements pflag.Value.String, printing this LockTime either as a timestamp in DateOnlyLayout or RFC822 layout, a duration or as an uint64.
type StringLoader ¶ added in v1.0.6
StringLoader defines the interface of a type (t), which can be loaded from a string, as well as being turned back into a string, such that `t.LoadString(str) == nil && t.String() == str`.
type StringLoaderFlag ¶ added in v1.0.6
type StringLoaderFlag struct {
StringLoader
}
StringLoaderFlag defines a utility type, allowing any StringLoader to be turned into a pflag-interface compatible type.
func (StringLoaderFlag) Set ¶ added in v1.0.6
func (s StringLoaderFlag) Set(str string) error
Set implements pflag.Value.Set, which parses the string using the StringLoader's LoadString method.
func (StringLoaderFlag) Type ¶ added in v1.0.6
func (s StringLoaderFlag) Type() string
Type implements pflag.Value.Type