mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-08 14:37:55 +08:00
47 lines
726 B
Go
47 lines
726 B
Go
package command
|
|
|
|
import (
|
|
"os/exec"
|
|
|
|
"yunion.io/x/log"
|
|
)
|
|
|
|
const (
|
|
PROTOCOL_TTY string = "tty"
|
|
//PROTOCOL_VNC string = "vnc"
|
|
)
|
|
|
|
type ICommand interface {
|
|
GetProtocol() string
|
|
GetCommand() *exec.Cmd
|
|
Cleanup() error
|
|
}
|
|
|
|
type BaseCommand struct {
|
|
name string
|
|
args []string
|
|
}
|
|
|
|
func NewBaseCommand(name string, args ...string) *BaseCommand {
|
|
return &BaseCommand{
|
|
name: name,
|
|
args: args,
|
|
}
|
|
}
|
|
|
|
func (c *BaseCommand) AppendArgs(args ...string) *BaseCommand {
|
|
for _, arg := range args {
|
|
c.args = append(c.args, arg)
|
|
}
|
|
return c
|
|
}
|
|
|
|
func (c BaseCommand) GetCommand() *exec.Cmd {
|
|
return exec.Command(c.name, c.args...)
|
|
}
|
|
|
|
func (c BaseCommand) Cleanup() error {
|
|
log.Infof("BaseCommand Cleanup do nothing")
|
|
return nil
|
|
}
|