Sync script
This commit is contained in:
parent
71f5781c86
commit
86d503d622
|
@ -1,12 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/localhots/empact/config"
|
||||
"github.com/localhots/empact/db"
|
||||
"github.com/localhots/empact/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
config.Load()
|
||||
if err := db.Connect(config.C().DatabaseURI); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/localhots/empact/config"
|
||||
"github.com/localhots/empact/db"
|
||||
"github.com/localhots/empact/task"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var token string
|
||||
flag.StringVar(&token, "token", "", "GitHub access token")
|
||||
flag.Parse()
|
||||
config.Load()
|
||||
if token == "" {
|
||||
fmt.Println("Access token is required")
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Connect(config.C().DatabaseURI); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
task.SyncUserOrgs(token)
|
||||
select {}
|
||||
}
|
|
@ -22,20 +22,16 @@ type (
|
|||
)
|
||||
|
||||
var (
|
||||
path string
|
||||
conf Config
|
||||
)
|
||||
|
||||
// Config is immutable and is always returned by value
|
||||
func C() Config {
|
||||
return conf
|
||||
func init() {
|
||||
flag.StringVar(&path, "config", "config.json", "Path to configuration file")
|
||||
}
|
||||
|
||||
func init() {
|
||||
func Load() {
|
||||
var err error
|
||||
var path string
|
||||
flag.StringVar(&path, "config", "config.json", "Path to configuration file")
|
||||
flag.Parse()
|
||||
|
||||
var fd *os.File
|
||||
if fd, err = os.Open(path); err != nil {
|
||||
panic(err)
|
||||
|
@ -51,3 +47,8 @@ func init() {
|
|||
log.SetOutput(os.Stderr)
|
||||
log.SetFlags(log.Ldate | log.Ltime)
|
||||
}
|
||||
|
||||
// Config is immutable and is always returned by value
|
||||
func C() Config {
|
||||
return conf
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue