Merge config package into main
This commit is contained in:
parent
bd86ce14f7
commit
222a1c09f0
2 changed files with 7 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package util
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -21,8 +21,7 @@ type keybindings struct {
|
|||
MessageInputFieldFocus string
|
||||
}
|
||||
|
||||
// Config consists of fields that can be customized by the user using the configuration file.
|
||||
type Config struct {
|
||||
type config struct {
|
||||
Token string
|
||||
Mouse bool
|
||||
Notifications bool
|
||||
|
|
@ -32,8 +31,7 @@ type Config struct {
|
|||
Keybindings keybindings
|
||||
}
|
||||
|
||||
// LoadConfig createsa new configuration file (if does not exist) and returns the default configuration or reads the existing configuration file from the default path.
|
||||
func LoadConfig() *Config {
|
||||
func loadConfig() *config {
|
||||
u, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -52,7 +50,7 @@ func LoadConfig() *Config {
|
|||
}
|
||||
defer f.Close()
|
||||
|
||||
c := Config{
|
||||
c := config{
|
||||
Mouse: true,
|
||||
Notifications: true,
|
||||
UserAgent: "" +
|
||||
|
|
@ -95,7 +93,7 @@ func LoadConfig() *Config {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
var c Config
|
||||
var c config
|
||||
if err = json.Unmarshal(d, &c); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
5
main.go
5
main.go
|
|
@ -3,7 +3,6 @@ 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"
|
||||
)
|
||||
|
|
@ -18,14 +17,14 @@ var (
|
|||
messageInputField *tview.InputField
|
||||
mainFlex *tview.Flex
|
||||
|
||||
conf *util.Config
|
||||
conf *config
|
||||
session *discordgo.Session
|
||||
selectedChannel *discordgo.Channel
|
||||
selectedMessage *discordgo.Message
|
||||
)
|
||||
|
||||
func main() {
|
||||
conf = util.LoadConfig()
|
||||
conf = loadConfig()
|
||||
tview.Styles = conf.Theme
|
||||
|
||||
app = tview.NewApplication()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue