-
Notifications
You must be signed in to change notification settings - Fork 38
/
label.go
62 lines (53 loc) · 1.27 KB
/
label.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
package main
import (
"errors"
"github.com/andreykaipov/goobs/api/requests/sources"
"github.com/muesli/coral"
)
var (
labelCmd = &coral.Command{
Use: "label",
Short: "manage text labels",
Long: `The label command manages text labels`,
RunE: nil,
}
textCmd = &coral.Command{
Use: "text",
Short: "Changes a text label",
RunE: func(cmd *coral.Command, args []string) error {
if len(args) < 2 {
return errors.New("text requires a source and the new text")
}
return changeLabel(args[0], args[1])
},
}
)
func changeLabel(source string, text string) error {
p := sources.GetTextFreetype2PropertiesParams{
Source: source,
}
resp, err := client.Sources.GetTextFreetype2Properties(&p)
if err != nil {
return err
}
r := sources.SetTextFreetype2PropertiesParams{
Source: source,
Color1: resp.Color1,
Color2: resp.Color2,
CustomWidth: resp.CustomWidth,
DropShadow: &resp.DropShadow,
Font: resp.Font,
FromFile: &resp.FromFile,
LogMode: &resp.LogMode,
Outline: &resp.Outline,
Text: text,
TextFile: resp.TextFile,
WordWrap: &resp.WordWrap,
}
_, err = client.Sources.SetTextFreetype2Properties(&r)
return err
}
func init() {
labelCmd.AddCommand(textCmd)
rootCmd.AddCommand(labelCmd)
}