-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (50 loc) · 1.25 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
package command
import (
"fmt"
"os"
"github.com/urfave/cli"
"github.com/robertgzr/xap/command/control"
"github.com/robertgzr/xap/command/player"
"github.com/robertgzr/xap/command/queue"
"github.com/robertgzr/xap/command/raw"
)
func App(version, commit, date string) *cli.App {
app := cli.NewApp()
app.Name = "xap"
app.Authors = []cli.Author{
cli.Author{Name: "robertgzr", Email: "r@gnzler.io"},
}
app.Version = version
app.Metadata = make(map[string]interface{})
app.Metadata["build_commit"] = commit
app.Metadata["build_date"] = date
app.Usage = "cli to remote control mpv player"
app.UsageText = "xap [global options] command [command options] [arguments...]"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "socket, S",
Usage: "filepath to the ipc socket",
Value: fmt.Sprintf("/var/run/user/%d/mpv", os.Getuid()),
},
}
app.Commands = []cli.Command{
control.Command,
control.PlayCommand,
control.PauseCommand,
control.StopCommand,
queue.Command,
queue.NowPlayingCommand,
queue.AddCommand,
queue.NextCommand,
queue.PrevCommand,
player.Command,
raw.Command,
}
app.Action = func(ctx *cli.Context) error {
if len(ctx.Args()) < 1 {
cli.ShowAppHelpAndExit(ctx, 1)
}
return RunDynamicSubcommand(ctx)
}
return app
}