-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
74 lines (65 loc) · 1.78 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"fmt"
"log"
"github.com/spf13/cobra"
midi "gitlab.com/gomidi/midi/v2"
)
const VERSION = "0.1.0-alpha"
var template string
var instrument string
var transmitter bool
var receiver bool
func main() {
rootCmd := &cobra.Command{
Use: "Seq",
Short: "A sequencer for your cli",
Long: "A sequencer for your cli",
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
midiConnection := InitMidiConnection()
defer midiConnection.Close()
loopMode := MLM_STAND_ALONE
if transmitter {
loopMode = MLM_TRANSMITTER
} else if receiver {
loopMode = MLM_RECEIVER
}
p := RunProgram(midiConnection, template, instrument, loopMode)
var err error
_, err = p.Run()
if err != nil {
log.Fatal("Program Failure")
} else {
return
}
},
}
cmdVersion := &cobra.Command{
Use: "version",
Short: "Version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("seq v%s\n", VERSION)
},
}
cmdListOutports := &cobra.Command{
Use: "list",
Short: "List available midi outports",
Run: func(cmd *cobra.Command, args []string) {
outports := midi.GetOutPorts()
for i, outport := range outports {
fmt.Printf("%d) %s\n", i+1, outport)
}
},
}
rootCmd.AddCommand(cmdListOutports)
rootCmd.AddCommand(cmdVersion)
rootCmd.Flags().StringVar(&template, "template", "Drums", "Choose a template (default: Drums)")
rootCmd.Flags().StringVar(&instrument, "instrument", "Standard", "Choose an instrument for CC integration (default: Standard)")
rootCmd.Flags().BoolVar(&transmitter, "transmitter", false, "Seq will run in transmitter mode")
rootCmd.Flags().BoolVar(&receiver, "receiver", false, "Seq will run in receiver mode")
err := rootCmd.Execute()
if err != nil {
log.Fatal("Program failed")
}
}