From c7fceb277d33f223930577f23ffcccdd7b1e50a5 Mon Sep 17 00:00:00 2001 From: acute_interpreter_panic <223899499+acute-interpreter-panic@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:19:32 +0200 Subject: [PATCH] added running of commands --- internal/cli/shell.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/internal/cli/shell.go b/internal/cli/shell.go index a513e05..d121045 100644 --- a/internal/cli/shell.go +++ b/internal/cli/shell.go @@ -126,21 +126,34 @@ func interpretCommand(command string, store musicObjectStore) (musicObjectStore, return append(store, currentMusicObjects), nil } -func Shell() { +func Shell(commandsList ...[]string) { plugin.RegisterPlugin(&plugin.Musify{}) + commands := []string{} + if len(commandsList) > 0 { + commands = commandsList[0] + } + fmt.Println("== MusicKraken Shell ==") fmt.Println() store := musicObjectStore{} + var err error = nil for { - fmt.Print("> ") + var command string - reader := bufio.NewReader(os.Stdin) - command, err := reader.ReadString('\n') - if err != nil { - log.Fatal(err) + if len(commands) <= 0 { + fmt.Print("> ") + + reader := bufio.NewReader(os.Stdin) + command, err = reader.ReadString('\n') + if err != nil { + log.Fatal(err) + } + } else { + command = commands[0] + commands = commands[1:] } store, err = interpretCommand(strings.TrimSpace(command), store)