diff --git a/main.go b/main.go index b4d321e..56da4a5 100644 --- a/main.go +++ b/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() diff --git a/config.go b/util/config.go similarity index 95% rename from config.go rename to util/config.go index f2cd188..abdf9a8 100644 --- a/config.go +++ b/util/config.go @@ -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) }