-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
83 lines (69 loc) · 1.99 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
75
76
77
78
79
80
81
82
83
// Copyright ©2022 Evolution. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Main entrypoint for ease application
package main
import (
"fmt"
"os"
"github.com/evolution-gaming/ease/internal/logging"
)
// root represents top level of ease command, including dispatching to subcommands.
func root(args []string) error {
usage := `Ease - Encoder Evaluation Suite
Usage:
ease <command> [arguments] [-h|-help]
The commands are:
run batch execute encodings according to "encoding plan"
vqmplot create plot for given metric from libvmaf JSON report
bitrate create bitrate plot of given video file
dump-conf output actual application configuration
new-plan helper to create anew plan configuration file
version print ease version and exit
Use "ease <command> -h|-help" for more information about command.`
if len(args) < 1 {
fmt.Println(usage)
return &AppError{msg: "please, specify command", exitCode: 2}
}
switch args[0] {
case "run":
return CreateRunCommand().Run(args[1:])
case "vqmplot":
return CreateVQMPlotCommand().Run(args[1:])
case "bitrate":
return CreateBitrateCommand().Run(args[1:])
case "dump-conf", "dump":
return CreateDumpConfCommand().Run(args[1:])
case "new-plan", "newp":
return CreateNewPlanCommand().Run(args[1:])
case "version":
printVersion()
return nil
case "-h", "-help", "--help", "?":
fmt.Println(usage)
return &AppError{
exitCode: 2,
}
default:
// No commands were matched at this point, so bail out with default usage message.
fmt.Println(usage)
return &AppError{
msg: "unknown command/flag",
exitCode: 2,
}
}
}
func main() {
// Enable info logger by default and early enough.
logging.EnableInfoLogger()
if err := root(os.Args[1:]); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
switch e := err.(type) {
case *AppError:
os.Exit(e.ExitCode())
default:
os.Exit(1)
}
}
os.Exit(0)
}