parent
732e292e44
commit
843f61d7aa
@ -1,8 +1,6 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gizak/termui"
|
||||
termbox "github.com/nsf/termbox-go"
|
||||
|
||||
@ -28,11 +26,11 @@ type AppContext struct {
|
||||
|
||||
// CreateAppContext creates an application context which can be passed
|
||||
// and referenced througout the application
|
||||
func CreateAppContext(flgConfig string) *AppContext {
|
||||
func CreateAppContext(flgConfig string) (*AppContext, error) {
|
||||
// Load config
|
||||
config, err := config.NewConfig(flgConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("ERROR: not able to load config file (%s): %s", flgConfig, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create Service
|
||||
@ -47,5 +45,5 @@ func CreateAppContext(flgConfig string) *AppContext {
|
||||
View: view,
|
||||
Config: config,
|
||||
Mode: CommandMode,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
9
main.go
9
main.go
@ -4,11 +4,13 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
|
||||
"github.com/erroneousboat/slack-term/context"
|
||||
"github.com/erroneousboat/slack-term/handlers"
|
||||
termbox "github.com/nsf/termbox-go"
|
||||
|
||||
"github.com/gizak/termui"
|
||||
)
|
||||
@ -74,7 +76,12 @@ func main() {
|
||||
termui.DefaultEvtStream = customEvtStream
|
||||
|
||||
// Create context
|
||||
ctx := context.CreateAppContext(flgConfig)
|
||||
ctx, err := context.CreateAppContext(flgConfig)
|
||||
if err != nil {
|
||||
termbox.Close()
|
||||
log.Println(err)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Setup body
|
||||
termui.Body.AddRows(
|
||||
|
Loading…
x
Reference in New Issue
Block a user