Segregate config.go to util package
This commit is contained in:
parent
d262054baf
commit
c858cc5c41
2 changed files with 8 additions and 8 deletions
6
main.go
6
main.go
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"github.com/ayntgl/discordgo"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rigormorrtiss/discordo/util"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/zalando/go-keyring"
|
||||
)
|
||||
|
|
@ -17,15 +18,14 @@ var (
|
|||
messageInputField *tview.InputField
|
||||
mainFlex *tview.Flex
|
||||
|
||||
conf *config
|
||||
|
||||
conf *util.Config
|
||||
session *discordgo.Session
|
||||
selectedChannel *discordgo.Channel
|
||||
selectedMessage *discordgo.Message
|
||||
)
|
||||
|
||||
func main() {
|
||||
conf = loadConfig()
|
||||
conf = util.LoadConfig()
|
||||
tview.Styles = conf.Theme
|
||||
|
||||
app = tview.NewApplication()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -21,7 +21,7 @@ type keybindings struct {
|
|||
MessageInputFieldFocus string
|
||||
}
|
||||
|
||||
type config struct {
|
||||
type Config struct {
|
||||
Token string
|
||||
Mouse bool
|
||||
Notifications bool
|
||||
|
|
@ -31,7 +31,7 @@ type config struct {
|
|||
Keybindings keybindings
|
||||
}
|
||||
|
||||
func loadConfig() *config {
|
||||
func LoadConfig() *Config {
|
||||
u, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -44,7 +44,7 @@ func loadConfig() *config {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
c := config{
|
||||
c := Config{
|
||||
Mouse: true,
|
||||
Notifications: true,
|
||||
UserAgent: "" +
|
||||
|
|
@ -85,7 +85,7 @@ func loadConfig() *config {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
var c config
|
||||
var c Config
|
||||
if err = json.Unmarshal(d, &c); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue