Documentation ¶
Overview ¶
Package command provides the ability to execute commands.
Index ¶
Constants ¶
const ( // CmdLs lists directory contents based on the current context. CmdLs = "ls" // CmdCd changes directory. CmdCd = "cd" // CmdGet downloads an object. CmdGet = "get" // CmdPut uploads an object. CmdPut = "put" // CmdPwd prints the present working directory. CmdPwd = "pwd" // CmdClear clears the current output. CmdClear = "clear" // CmdExit exits the program. CmdExit = "exit" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CdCommand ¶
type CdCommand struct {
// contains filtered or unexported fields
}
CdCommand simulates 'cd' functionality.
func (CdCommand) IsLongRunning ¶
IsLongRunning returns true when an S3 API call is required prior to changing directory.
type ClearCommand ¶
type ClearCommand struct{}
ClearCommand simulates 'clear' functionality.
func (ClearCommand) Execute ¶
func (clear ClearCommand) Execute(out Outputter) error
Execute performs a 'clear' command by clearing the current program output. Note: Only applicable when running via command line.
func (ClearCommand) IsLongRunning ¶
func (ClearCommand) IsLongRunning() bool
IsLongRunning returns false because 'clear' can execute without delay.
type Executor ¶
type Executor interface { // Execute runs the command. Execute(Outputter) error // IsLongRunning indicates if the command may require a waiting period (ie. remote commands). IsLongRunning() bool }
Executor defines an interface for executable instructions.
type ExitCommand ¶
type ExitCommand struct { }
ExitCommand simulates 'exit' functionality.
func (ExitCommand) Execute ¶
func (exit ExitCommand) Execute(out Outputter) error
Execute performs an 'exit' command by quitting the program.
func (ExitCommand) IsLongRunning ¶
func (ExitCommand) IsLongRunning() bool
IsLongRunning returns false because 'exit' can execute without delay.
type GetCommand ¶
type GetCommand struct {
// contains filtered or unexported fields
}
GetCommand downloads a remote file.
func NewGet ¶
func NewGet(s3 S3Client, con *context.Context, args []string) GetCommand
NewGet initializes and returns a GetCommand.
func (GetCommand) Execute ¶
func (get GetCommand) Execute(out Outputter) error
Execute performs a 'get' by downloading a remote file to a local destination.
func (GetCommand) IsLongRunning ¶
func (GetCommand) IsLongRunning() bool
IsLongRunning returns true because a 'get' is always long running.
type LsCommand ¶
type LsCommand struct {
// contains filtered or unexported fields
}
LsCommand simulates 'ls' functionality.
func (LsCommand) Execute ¶
Execute performs a 'ls' command by printing the buckets/objects in the pwd based on the underlying context.
func (LsCommand) IsLongRunning ¶
IsLongRunning returns true because 'ls' requires a network operation.
type Outputter ¶
type Outputter interface {
Write(string)
}
Outputter defines a type that can receive command output in the form of strings.
type PutCommand ¶
type PutCommand struct {
// contains filtered or unexported fields
}
PutCommand uploads an object.
func NewPut ¶
func NewPut(s3 S3Client, con *context.Context, args []string) PutCommand
NewPut initializes and returns a PutCommand.
func (PutCommand) Execute ¶
func (p PutCommand) Execute(out Outputter) error
Execute performs a 'put' command by uploading a file to S3.
func (PutCommand) IsLongRunning ¶
func (PutCommand) IsLongRunning() bool
IsLongRunning returns true because 'put' must always perform network requests.
type PwdCommand ¶
type PwdCommand struct {
// contains filtered or unexported fields
}
PwdCommand simulates 'pwd' functionality.
func NewPwd ¶
func NewPwd(con *context.Context) PwdCommand
NewPwd initializes and returns a PwdCommand.
func (PwdCommand) Execute ¶
func (pwd PwdCommand) Execute(out Outputter) error
Execute performs a 'pwd' command by printing the current working path.
func (PwdCommand) IsLongRunning ¶
func (PwdCommand) IsLongRunning() bool
IsLongRunning returns false because 'pwd' can execute without delay.
type S3Client ¶
type S3Client interface { LsBuckets() ([]string, error) LsObjects(bucket, prefix string) ([]string, error) BucketExists(string) (bool, error) ObjectExists(string, string) (bool, error) PathExists(string, string) (bool, error) DownloadObject(string, string) (string, error) UploadObject(string, string, *os.File) (string, error) }
S3Client defines an interface that communicates with Amazon S3.