func main() { fmt.Println(` Enter following commands to control the player: lib list -- View the existing music lib lib add <name> <artist> <source> <type> -- Add a music to the music lib lib remove <name> -- Remove the specified music from the lib play <name> -- Play the specified music `) lib = mlib.NewMusicManager() r := bufio.NewReader(os.Stdin) for { fmt.Print("Enter command-> ") rawLine, _, _ := r.ReadLine() line := string(rawLine) if line == "q" || line == "e" { break } tokens := strings.Split(line, " ") if tokens[0] == "lib" { handleLibCommands(tokens) } else if tokens[0] == "play" { handlePlayCommand(tokens) } else { fmt.Println("Unrecognized command:", tokens[0]) } } }
func main() { fmt.Println(USAGE) lib = mlib.NewMusicManager() r := bufio.NewReader(os.Stdin) for { fmt.Println("Enter command-> ") rawLine, _, _ := r.ReadLine() line := string(rawLine) if line == "q" || line == "e" { break } tokens := strings.Split(line, " ") switch tokens[0] { case "lib": handleLibCommands(tokens) case "play": handlePlayCommands(tokens) default: fmt.Println("Unrecognized command:", tokens[0]) } } }