erroneousboat-slack-term/main.go

74 lines
1.0 KiB
Go
Raw Normal View History

2016-09-11 17:55:19 +02:00
package main
import (
2016-09-25 22:34:02 +02:00
"flag"
2016-10-09 18:37:00 +02:00
"fmt"
2016-09-25 22:34:02 +02:00
"log"
"net/http"
_ "net/http/pprof"
2016-09-25 22:34:02 +02:00
"os/user"
"path"
2017-08-19 23:31:16 +02:00
"github.com/erroneousboat/slack-term/context"
"github.com/erroneousboat/slack-term/handlers"
2016-09-11 17:55:19 +02:00
)
2016-10-09 18:37:00 +02:00
const (
2017-09-02 16:51:21 +02:00
VERSION = "v2.0.0"
2016-10-30 14:26:12 +01:00
USAGE = `NAME:
2016-10-09 18:37:00 +02:00
slack-term - slack client for your terminal
USAGE:
slack-term -config [path-to-config]
VERSION:
%s
GLOBAL OPTIONS:
--help, -h
`
)
var (
flgConfig string
flgUsage bool
)
2016-09-11 17:55:19 +02:00
2016-10-09 18:37:00 +02:00
func init() {
2016-09-25 22:34:02 +02:00
// Get home dir for config file default
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
// Parse flags
2016-10-09 18:37:00 +02:00
flag.StringVar(
&flgConfig,
2016-09-25 22:34:02 +02:00
"config",
path.Join(usr.HomeDir, "slack-term.json"),
"location of config file",
)
2016-10-09 18:37:00 +02:00
flag.Usage = func() {
fmt.Printf(USAGE, VERSION)
}
2016-09-25 22:34:02 +02:00
flag.Parse()
2016-10-09 18:37:00 +02:00
}
func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
2016-09-25 22:34:02 +02:00
// Create context
2017-08-19 23:31:16 +02:00
appCTX, err := context.CreateAppContext(flgConfig)
if err != nil {
2017-08-19 23:31:16 +02:00
log.Fatal(err)
}
2017-08-19 23:31:16 +02:00
defer appCTX.View.GUI.Close()
2016-09-11 17:55:19 +02:00
2016-09-25 22:34:02 +02:00
// Register handlers
handlers.RegisterEventHandlers(appCTX)
2016-09-11 17:55:19 +02:00
}