Documentation
¶
Index ¶
- Variables
- func Confirm(info string) (bool, error)
- func FormatString(t MessageType, m Message) string
- func FormatStringWithTrans(t MessageType, m MessageWithTranslation) string
- func JSONString(out interface{}) string
- func NewError(code ErrorCode, info string, pre error) error
- func PrintError(err error) error
- func PrintInfo(info string)
- func PrintQuery(query string)
- func PrintResult(result string)
- func RequireInteractive(prompt string) error
- type ConfirmationMessage
- type ErrorCode
- type ErrorMessage
- type Message
- type MessageType
- type MessageWithTranslation
- type Output
- type StringMessage
Constants ¶
This section is empty.
Variables ¶
var Format string
Format is the target of output-format flag
var NonInteractive bool
NonInteractive when set, interactive prompts return error instead of waiting for input. Automatically set when stdin is not a terminal, or via --non-interactive flag / IOCTL_NON_INTERACTIVE=1 env.
var Quiet bool
Quiet when set, suppresses informational lines (e.g. "Blockchain Node: ...") and only outputs data.
Functions ¶
func Confirm ¶ added in v2.3.6
Confirm displays a confirmation prompt and waits for user to type "yes". In non-interactive mode it returns (false, error). If the user types anything other than "yes", it returns (false, nil). Only returns (true, nil) on "yes".
func FormatString ¶
func FormatString(t MessageType, m Message) string
FormatString returns Output as string in certain format
func FormatStringWithTrans ¶
func FormatStringWithTrans(t MessageType, m MessageWithTranslation) string
FormatStringWithTrans returns Output as string in certain format supporting multi languages
func JSONString ¶
func JSONString(out interface{}) string
JSONString returns json string for message
func NewError ¶
NewError and returns golang error that contains Error Message ErrorCode can pass zero only when previous error is always a format error that contains non-zero error code. ErrorCode passes 0 means that I want to use previous error's code rather than override it. If there is no previous error, newInfo should not be empty.
func PrintError ¶
PrintError prints Error Message in format, only used at top layer of a command
func PrintInfo ¶ added in v2.3.6
func PrintInfo(info string)
PrintInfo prints an informational line (e.g. "Blockchain Node: ...") that is suppressed in quiet mode.
func RequireInteractive ¶ added in v2.3.6
RequireInteractive returns an error if non-interactive mode is set. Use this to guard interactive prompts (fmt.Scanf, etc.).
Types ¶
type ConfirmationMessage ¶
ConfirmationMessage is the struct of an Confirmation output
func (*ConfirmationMessage) String ¶
func (m *ConfirmationMessage) String() string
type ErrorCode ¶
type ErrorCode int
ErrorCode is the code of error
const ( // UndefinedError used when an error cat't be classified UndefinedError ErrorCode = iota // UpdateError used when an error occurs when running update command UpdateError // RuntimeError used when an error occurs in runtime RuntimeError // NetworkError used when an network error is happened NetworkError // APIError used when an API error is happened APIError // ValidationError used when validation is not passed ValidationError // SerializationError used when marshal or unmarshal meets error SerializationError // ReadFileError used when error occurs during reading a file ReadFileError // WriteFileError used when error occurs during writing a file WriteFileError // FlagError used when invalid flag is set FlagError // ConvertError used when fail to converting data ConvertError // CryptoError used when crypto error occurs CryptoError // AddressError used if an error is related to address AddressError // InputError used when error about input occurs InputError // KeystoreError used when an error related to keystore KeystoreError // ConfigError used when an error about config occurs ConfigError // InstantiationError used when an error during instantiation InstantiationError // CompilerError used when an error occurs when using the solidity compiler CompilerError )
type ErrorMessage ¶
ErrorMessage is the struct of an Error output
func (*ErrorMessage) String ¶
func (m *ErrorMessage) String() string
type MessageType ¶
type MessageType int
MessageType marks the type of output message
const ( // Result represents the result of a command Result MessageType = iota // Confirmation represents request for confirmation Confirmation // Query represents request for answer of certain question Query // Error represents error occurred when running a command Error // Warn represents non-fatal mistake occurred when running a command Warn )
func (MessageType) MarshalJSON ¶ added in v2.3.6
func (t MessageType) MarshalJSON() ([]byte, error)
MarshalJSON marshals MessageType as a human-readable string
type MessageWithTranslation ¶
MessageWithTranslation is the message part of output supporting multi languages
type Output ¶
type Output struct {
MessageType MessageType `json:"messageType"`
Message Message `json:"message"`
MessageWithTranslation MessageWithTranslation `json:"messageWithTranslation,omitempty"`
}
Output is used for format output
type StringMessage ¶
type StringMessage string
StringMessage is the Message for string
func (StringMessage) String ¶
func (m StringMessage) String() string