-
Notifications
You must be signed in to change notification settings - Fork 11
/
octoscan.go
53 lines (38 loc) · 926 Bytes
/
octoscan.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
package main
import (
"fmt"
"os"
"github.com/synacktiv/octoscan/cmd"
"github.com/synacktiv/octoscan/common"
"github.com/docopt/docopt-go"
)
var usage = `octoscan
Usage:
octoscan [-hv] <command> [<args>...]
Options:
-h, --help
-v, --version
Commands:
dl Download workflows files from GitHub
scan Scan workflows
`
func main() {
parser := &docopt.Parser{OptionsFirst: true}
args, _ := parser.ParseArgs(usage, nil, "octoscan version 0.1")
cmd, _ := args.String("<command>")
cmdArgs := args["<args>"].([]string)
err := runCommand(cmd, cmdArgs)
os.Exit(err)
}
func runCommand(command string, args []string) int {
argv := append([]string{command}, args...)
switch command {
case "scan":
return cmd.Scan(argv)
case "dl":
return cmd.Download(argv)
default:
common.Log.Info(fmt.Sprintf("%s is not a octoscan command. See 'octoscan --help'", command))
return common.ExitStatusFailure
}
}