Documentation ¶
Overview ¶
Package cmd provides for the interpretation of commands from a user interface, either email or rpc.
See command.go for information on the available commands and instructions on how to implement more commands.
Index ¶
- Constants
- Variables
- func DisableLog()
- func EmailCommand(u User, from, agent, name string, params []string) *email.Bmail
- func PublicToRPC(ip PublicID) *rpc.BitmessageIdentity
- func RPCCommand(u User, request *pb.BMRPCRequest) (*pb.BMRPCReply, error)
- func ReadPattern(params []string, elements ...interface{}) error
- func SubjectRe(cmd string, p []string) string
- func UseLogger(logger btclog.Logger)
- func ØMQServer()
- type Command
- type ErrInvalidNumberOfParameters
- type ErrUnimplemented
- type ErrUnknownCommand
- type ErrUnrecognizedPattern
- type Key
- type Pattern
- type PublicID
- type RPCClient
- type RPCServer
- type Response
- type User
Constants ¶
const DefaultSendAck = true
DefaultSendAck is set to true, which means that new addresses by default return ack messages.
Variables ¶
var ( // ErrInvalidString is returned when a string is expected but // the given input does not match the string pattern. ErrInvalidString = errors.New("Invalid string pattern. Should be delimited by \" ") // ErrInvalidBoolean is returned when a boolean is expected but // the given input does not match boolean type. ErrInvalidBoolean = errors.New("Boolean should be 'true' or 'false'") // ErrInvalidSymbol is returned when a boolean is expected but // the given input does not match boolean type. ErrInvalidSymbol = errors.New("Boolean should be 'true' or 'false'") // ErrInvalidType is returned when the type provided cannot be read. ErrInvalidType = errors.New("Cannot read the given type.") // ErrInvalidRPCRequest is returned when an rpc request is invalid. ErrInvalidRPCRequest = errors.New("Invalid rpc request.") )
var Commands = []string{
"deletemessages",
"getmessages",
"help",
"listaddresses",
"newaddress",
"sendmessage",
}
Commands is the list of commands.
var ErrServerStopped = errors.New("Server is not running.")
ErrServerStopped is returned when an rpc call is made and the server isn't running.
var Unimplemented = []string{
"deletemessages",
"getmessages",
"listaddresses",
"newaddress",
"sendmessage",
}
Unimplemented is the list of unimplemented commands.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func EmailCommand ¶
EmailCommand manages a request sent via the email interface.
func PublicToRPC ¶
func PublicToRPC(ip PublicID) *rpc.BitmessageIdentity
PublicToRPC converts an identity.Public to a BitmessageIdentity
func RPCCommand ¶
func RPCCommand(u User, request *pb.BMRPCRequest) (*pb.BMRPCReply, error)
RPCCommand manages a request sent via an rpc interface.
func ReadPattern ¶
ReadPattern attempts to return a type corresponding to the given pattern which is read from the given string.
Types ¶
type Command ¶
Command is the type created from the input through the user interface, either via email or via rpc.
func BuildCommand ¶
func BuildCommand(r *pb.BMRPCRequest) (Command, error)
BuildCommand translates an rpc request into a Command type.
type ErrInvalidNumberOfParameters ¶
type ErrInvalidNumberOfParameters struct {
// contains filtered or unexported fields
}
ErrInvalidNumberOfParameters is an error representing an invalid number of parameters.
func (*ErrInvalidNumberOfParameters) Error ¶
func (err *ErrInvalidNumberOfParameters) Error() string
type ErrUnimplemented ¶
type ErrUnimplemented struct {
Command string
}
ErrUnimplemented implements the error interface and is returned when a user calls an unimplemented command.
func (*ErrUnimplemented) Error ¶
func (err *ErrUnimplemented) Error() string
Error constructs the error message as a string.
type ErrUnknownCommand ¶
type ErrUnknownCommand struct {
Command string
}
ErrUnknownCommand implements the error interface and is returned when a user calls an unknown command.
func (*ErrUnknownCommand) Error ¶
func (err *ErrUnknownCommand) Error() string
Error constructs the error message as a string.
type ErrUnrecognizedPattern ¶
type ErrUnrecognizedPattern struct {
// contains filtered or unexported fields
}
ErrUnrecognizedPattern implements the error interface and and is returned when the user provides an unrecognized pattern.
func (*ErrUnrecognizedPattern) Error ¶
func (err *ErrUnrecognizedPattern) Error() string
Error constructs the error message as a string.
type Key ¶
type Key uint32
Key is an element of the patterns used to define command parameters for email requests.
const ( // KeyRepeated is written +, represents any positive number of repetitions // of the previous pattern element. KeyRepeated Key = Key(0) // KeyRepeatedNull is written * represents any number of repetitions of // the previous pattern element, including zero. KeyRepeatedNull Key = Key(1) // KeyBoolean represents a boolean value. KeyBoolean Key = Key(2) // KeyNatural represents a natural number value. KeyNatural Key = Key(3) // KeyString represents a string value. KeyString Key = Key(4) // KeySymbol represents a symbol value. KeySymbol Key = Key(5) )
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern represents a valid way of interpreting a command with a set of parameters.
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
func GRPCClient ¶
func GRPCClient(cfg *bmrpc.ClientConfig) (*RPCClient, error)
GRPCClient creates the GRPC client.
func (*RPCClient) Request ¶
func (r *RPCClient) Request(in *pb.BMRPCRequest) (*pb.BMRPCReply, error)
type RPCServer ¶
RPCServer is a server that can listen and execute rpc commands.
func GRPCServer ¶
GRPCServer creates a grpc GRPC server.
func (*RPCServer) BMAgentRequest ¶
func (s *RPCServer) BMAgentRequest(ctx context.Context, req *pb.BMRPCRequest) (*pb.BMRPCReply, error)
BMAgentRequest returns the feature at the given point.
type Response ¶
type Response interface { String() string RPC() *rpc.BMRPCReply }
Response is the type returned by a command. It can be delivered to the user as a json object or as an email.
func ErrorResponse ¶
ErrorResponse creates an errorResponse object.