From 192100c0590dfbe2db498b356fbd1e1e19eace2c Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Fri, 7 Jan 2022 18:17:07 +0100 Subject: Added very based CLI --- solo_tool_cli.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 solo_tool_cli.py (limited to 'solo_tool_cli.py') diff --git a/solo_tool_cli.py b/solo_tool_cli.py new file mode 100644 index 0000000..b6e7817 --- /dev/null +++ b/solo_tool_cli.py @@ -0,0 +1,34 @@ +from solo_tool import SoloTool +from midi_controller_launchpad_mini import MidiController + +class SoloToolCLI: + def __init__(self, sessionJson, soloToolOverride=None, midiOverride=None): + self._soloTool = SoloTool() if soloToolOverride is None else soloToolOverride + self._soloTool.loadSession(sessionJson) + self._midiController = MidiController() if midiOverride is None else midiOverride + self._commands = { + "song" : self._song, + "midi" : self._midi + } + + def input(self, commandString): + split = commandString.strip().split(" ") + if split[0] in self._commands: + self._commands[split[0]](split[1:]) + + def _song(self, args): + if len(args) > 0: + self._soloTool.setSong(int(args[0])) + else: + songs = self._soloTool.getSongs() + print("Songs:") + for i, s in enumerate(songs): + print(f" {i} {s}") + + def _midi(self, args): + if len(args) > 0 and args[0] == "connect": + print("Connecting to MIDI device...") + self._midiController.connect() + else: + print("Supported device: Novation Launchpad Mini MkII") + -- cgit v1.2.3