-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.go
49 lines (41 loc) · 1.52 KB
/
cli.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
// This file has been created by "go generate" as initial code. go generate will never update it, EXCEPT if you remove it.
// So, update it for your need.
package main
import (
"github.com/forj-oss/goforjj"
"gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/yaml.v2"
"log"
)
type GithubApp struct {
App *kingpin.Application
params Params
socket string
Yaml goforjj.YamlPlugin
}
type Params struct {
socket_file *string
socket_path *string
daemon *bool // Currently not used - Lot of concerns with daemonize in go... Stay in foreground
}
func (a *GithubApp) init() {
a.load_plugin_def()
a.App = kingpin.New("github", "Upstream github plugin for FORJJ. It properly configure github.com or entreprise with organisation/repos")
version := "0.1"
if version != "" {
a.App.Version(version)
}
// true to create the Infra
daemon := a.App.Command("service", "github REST API service")
daemon.Command("start", "start github REST API service")
a.params.socket_file = daemon.Flag("socket-file", "Socket file to use").Default(a.Yaml.Runtime.Service.Socket).String()
a.params.socket_path = daemon.Flag("socket-path", "Socket file path to use").Default("/tmp/forjj-socks").String()
a.params.daemon = daemon.Flag("daemon", "Start process in background like a daemon").Short('d').Bool()
}
func (a *GithubApp) load_plugin_def() {
yaml.Unmarshal([]byte(YamlDesc), &a.Yaml)
if a.Yaml.Runtime.Service.Socket == "" {
a.Yaml.Runtime.Service.Socket = "github.sock"
log.Printf("Set default socket file: %s", a.Yaml.Runtime.Service.Socket)
}
}