-
Notifications
You must be signed in to change notification settings - Fork 2
/
nmapa.go
50 lines (42 loc) · 1020 Bytes
/
nmapa.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
package main
import (
"flag"
"fmt"
"os"
"github.com/scgolang/sc"
)
// Nmapa sets a node's control value.
type Nmapa struct {
Controls map[string]float32
NodeID int
flagErrorHandling flag.ErrorHandling
scc *sc.Client
}
// Run runs the command.
func (nmapa Nmapa) Run(args []string) error {
fs := flag.NewFlagSet("nmapa", flagErrorHandling)
fs.IntVar(&nmapa.NodeID, "id", 0, "node ID")
if err := fs.Parse(args); err != nil {
return ErrUsage
}
if nmapa.NodeID <= 0 {
return ErrUsage
}
if len(fs.Args()) == 0 {
return ErrUsage // Print a usage message if there are no kv pairs.
}
busMapping, ok := getBusMapping(fs.Args())
if !ok {
return ErrUsage
}
return nmapa.scc.NodeMapa(int32(nmapa.NodeID), busMapping)
}
// Usage prints a usage message.
func (nmapa Nmapa) Usage() {
fmt.Fprint(os.Stderr, `
scc [GLOBAL OPTIONS] nmapa [OPTIONS] CTL=VALUE [... CTL=VALUE]
OPTIONS
-id (REQUIRED) Node ID.
CTL must be a string and VALUE must be an audio bus index (integer).
`)
}