added running of commands
This commit is contained in:
@@ -126,22 +126,35 @@ func interpretCommand(command string, store musicObjectStore) (musicObjectStore,
|
|||||||
return append(store, currentMusicObjects), nil
|
return append(store, currentMusicObjects), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Shell() {
|
func Shell(commandsList ...[]string) {
|
||||||
plugin.RegisterPlugin(&plugin.Musify{})
|
plugin.RegisterPlugin(&plugin.Musify{})
|
||||||
|
|
||||||
|
commands := []string{}
|
||||||
|
if len(commandsList) > 0 {
|
||||||
|
commands = commandsList[0]
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("== MusicKraken Shell ==")
|
fmt.Println("== MusicKraken Shell ==")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
store := musicObjectStore{}
|
store := musicObjectStore{}
|
||||||
|
var err error = nil
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
var command string
|
||||||
|
|
||||||
|
if len(commands) <= 0 {
|
||||||
fmt.Print("> ")
|
fmt.Print("> ")
|
||||||
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
command, err := reader.ReadString('\n')
|
command, err = reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
command = commands[0]
|
||||||
|
commands = commands[1:]
|
||||||
|
}
|
||||||
|
|
||||||
store, err = interpretCommand(strings.TrimSpace(command), store)
|
store, err = interpretCommand(strings.TrimSpace(command), store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user