Added the clone command in SSM
This commit is contained in:
parent
ee6011bc3e
commit
306640abdb
9 changed files with 102 additions and 10 deletions
|
|
@ -2,6 +2,8 @@ package commandctrl
|
|||
|
||||
import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/pkg/errors"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/lmika/awstools/internal/common/ui/events"
|
||||
|
|
@ -35,15 +37,18 @@ func (c *CommandController) Prompt() tea.Cmd {
|
|||
}
|
||||
|
||||
func (c *CommandController) Execute(commandInput string) tea.Cmd {
|
||||
log.Println("Received input: ", commandInput)
|
||||
input := strings.TrimSpace(commandInput)
|
||||
if input == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
tokens := shellwords.Split(input)
|
||||
log.Println("Tokens: ", tokens)
|
||||
command := c.lookupCommand(tokens[0])
|
||||
if command == nil {
|
||||
return events.SetStatus("no such command: " + tokens[0])
|
||||
log.Println("No such command: ", tokens)
|
||||
return events.SetError(errors.New("no such command: " + tokens[0]))
|
||||
}
|
||||
|
||||
return command(tokens[1:])
|
||||
|
|
@ -51,6 +56,7 @@ func (c *CommandController) Execute(commandInput string) tea.Cmd {
|
|||
|
||||
func (c *CommandController) lookupCommand(name string) Command {
|
||||
for ctx := c.commandList; ctx != nil; ctx = ctx.parent {
|
||||
log.Printf("Looking in command list: %v", c.commandList)
|
||||
if cmd, ok := ctx.Commands[name]; ok {
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue