From bb7f85a296c24352540ff01300164dc2b97524ef Mon Sep 17 00:00:00 2001 From: "ailan.gl" Date: Tue, 20 Mar 2018 18:02:56 +0800 Subject: [PATCH] expose Commander.GetCommand() for integration with aliyun-cli. --- lib/command.go | 1 + lib/config.go | 4 ++++ lib/cp.go | 4 ++++ lib/create_symlink.go | 4 ++++ lib/hash.go | 4 ++++ lib/help.go | 4 ++++ lib/ls.go | 4 ++++ lib/mb.go | 4 ++++ lib/read_symlink.go | 4 ++++ lib/restore.go | 4 ++++ lib/rm.go | 4 ++++ lib/set_acl.go | 4 ++++ lib/set_meta.go | 4 ++++ lib/signurl.go | 4 ++++ lib/stat.go | 4 ++++ lib/update.go | 6 ++++++ 16 files changed, 63 insertions(+) diff --git a/lib/command.go b/lib/command.go index 07e82ee9..ce99463e 100644 --- a/lib/command.go +++ b/lib/command.go @@ -52,6 +52,7 @@ type Command struct { // Commander is the interface of all commands type Commander interface { RunCommand() error + GetCommand() *Command Init(args []string, options OptionMapType) error } diff --git a/lib/config.go b/lib/config.go index caa9907e..bcd2517d 100644 --- a/lib/config.go +++ b/lib/config.go @@ -286,6 +286,10 @@ type ConfigCommand struct { command Command } +func (cc *ConfigCommand) GetCommand() (*Command) { + return &cc.command +} + var configCommand = ConfigCommand{ command: Command{ name: "config", diff --git a/lib/cp.go b/lib/cp.go index 4a73d6bc..bc625225 100644 --- a/lib/cp.go +++ b/lib/cp.go @@ -1133,6 +1133,10 @@ var copyCommand = CopyCommand{ }, } +func (cc *CopyCommand) GetCommand() *Command { + return &cc.command +} + // function for FormatHelper interface func (cc *CopyCommand) formatHelpForWhole() string { return cc.command.formatHelpForWhole() diff --git a/lib/create_symlink.go b/lib/create_symlink.go index a01b9316..c28c7984 100644 --- a/lib/create_symlink.go +++ b/lib/create_symlink.go @@ -108,6 +108,10 @@ var createSymlinkCommand = CreateSymlinkCommand{ }, } +func (cc *CreateSymlinkCommand) GetCommand() *Command { + return &cc.command +} + // function for FormatHelper interface func (cc *CreateSymlinkCommand) formatHelpForWhole() string { return cc.command.formatHelpForWhole() diff --git a/lib/hash.go b/lib/hash.go index dbdbc2c4..bf4dacb6 100644 --- a/lib/hash.go +++ b/lib/hash.go @@ -125,6 +125,10 @@ var hashCommand = HashCommand{ }, } +func (hc *HashCommand) GetCommand() *Command { + return &hc.command +} + // function for RewriteLoadConfiger interface func (hc *HashCommand) rewriteLoadConfig(configFile string) error { // read config file, if error exist, do not print error diff --git a/lib/help.go b/lib/help.go index 997eb334..4d40b2e9 100644 --- a/lib/help.go +++ b/lib/help.go @@ -99,6 +99,10 @@ var helpCommand = HelpCommand{ }, } +func (hc *HelpCommand) GetCommand() *Command { + return &hc.command +} + // function for RewriteLoadConfiger interface func (hc *HelpCommand) rewriteLoadConfig(configFile string) error { // read config file, if error exist, do not print error diff --git a/lib/ls.go b/lib/ls.go index d3087ef1..74bc1364 100644 --- a/lib/ls.go +++ b/lib/ls.go @@ -350,6 +350,10 @@ var listCommand = ListCommand{ }, } +func (lc *ListCommand) GetCommand() *Command { + return &lc.command +} + // function for FormatHelper interface func (lc *ListCommand) formatHelpForWhole() string { return lc.command.formatHelpForWhole() diff --git a/lib/mb.go b/lib/mb.go index bcf78887..ecdc7a9f 100644 --- a/lib/mb.go +++ b/lib/mb.go @@ -153,6 +153,10 @@ var makeBucketCommand = MakeBucketCommand{ }, } +func (mc *MakeBucketCommand) GetCommand() *Command { + return &mc.command +} + // function for FormatHelper interface func (mc *MakeBucketCommand) formatHelpForWhole() string { return mc.command.formatHelpForWhole() diff --git a/lib/read_symlink.go b/lib/read_symlink.go index 74e55429..65ad9852 100644 --- a/lib/read_symlink.go +++ b/lib/read_symlink.go @@ -104,6 +104,10 @@ var readSymlinkCommand = ReadSymlinkCommand{ }, } +func (rc *ReadSymlinkCommand) GetCommand() *Command { + return &rc.command +} + // function for FormatHelper interface func (rc *ReadSymlinkCommand) formatHelpForWhole() string { return rc.command.formatHelpForWhole() diff --git a/lib/restore.go b/lib/restore.go index 0380c890..8d59801e 100644 --- a/lib/restore.go +++ b/lib/restore.go @@ -153,6 +153,10 @@ var restoreCommand = RestoreCommand{ }, } +func (rc *RestoreCommand) GetCommand() *Command { + return &rc.command +} + // function for FormatHelper interface func (rc *RestoreCommand) formatHelpForWhole() string { return rc.command.formatHelpForWhole() diff --git a/lib/rm.go b/lib/rm.go index 0585bd46..8604d6b0 100644 --- a/lib/rm.go +++ b/lib/rm.go @@ -263,6 +263,10 @@ var removeCommand = RemoveCommand{ }, } +func (rc *RemoveCommand) GetCommand() *Command { + return &rc.command +} + // function for FormatHelper interface func (rc *RemoveCommand) formatHelpForWhole() string { return rc.command.formatHelpForWhole() diff --git a/lib/set_acl.go b/lib/set_acl.go index 59a17082..b3e57698 100644 --- a/lib/set_acl.go +++ b/lib/set_acl.go @@ -243,6 +243,10 @@ var setACLCommand = SetACLCommand{ }, } +func (sc *SetACLCommand) GetCommand() *Command { + return &sc.command +} + // function for FormatHelper interface func (sc *SetACLCommand) formatHelpForWhole() string { return sc.command.formatHelpForWhole() diff --git a/lib/set_meta.go b/lib/set_meta.go index 6e8e8a0f..297912e5 100644 --- a/lib/set_meta.go +++ b/lib/set_meta.go @@ -284,6 +284,10 @@ var setMetaCommand = SetMetaCommand{ }, } +func (sc *SetMetaCommand) GetCommand() *Command { + return &sc.command +} + // function for FormatHelper interface func (sc *SetMetaCommand) formatHelpForWhole() string { return sc.command.formatHelpForWhole() diff --git a/lib/signurl.go b/lib/signurl.go index 1feda30d..c2431079 100644 --- a/lib/signurl.go +++ b/lib/signurl.go @@ -97,6 +97,10 @@ var signURLCommand = SignurlCommand{ }, } +func (sc *SignurlCommand) GetCommand() *Command { + return &sc.command +} + // function for FormatHelper interface func (sc *SignurlCommand) formatHelpForWhole() string { return sc.command.formatHelpForWhole() diff --git a/lib/stat.go b/lib/stat.go index 25aa5750..9eab9367 100644 --- a/lib/stat.go +++ b/lib/stat.go @@ -104,6 +104,10 @@ var statCommand = StatCommand{ }, } +func (sc *StatCommand) GetCommand() *Command { + return &sc.command +} + // function for FormatHelper interface func (sc *StatCommand) formatHelpForWhole() string { return sc.command.formatHelpForWhole() diff --git a/lib/update.go b/lib/update.go index af2f8823..74180a42 100644 --- a/lib/update.go +++ b/lib/update.go @@ -83,6 +83,12 @@ var updateCommand = UpdateCommand{ }, } + +func (uc *UpdateCommand) GetCommand() *Command { + return &uc.command +} + + // function for RewriteLoadConfiger interface func (uc *UpdateCommand) rewriteLoadConfig(configFile string) error { // read config file, if error exist, do not print error