forked from synacktiv/octoscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoctoscan.go
55 lines (40 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
54
55
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)
if err != nil {
os.Exit(1)
}
}
func runCommand(command string, args []string) error {
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 nil
}
}