Bläddra i källkod

Revert previous commit

ayn2op 3 år sedan
förälder
incheckning
5a0d5e2aa1
5 ändrade filer med 65 tillägg och 69 borttagningar
  1. 58 4
      config.go
  2. 0 30
      config/keys.go
  3. 0 26
      config/theme.go
  4. 5 6
      main.go
  5. 2 3
      state.go

+ 58 - 4
config/config.go → config.go

@@ -1,4 +1,4 @@
-package config
+package main
 
 import (
 	"os"
@@ -7,7 +7,61 @@ import (
 	"gopkg.in/yaml.v3"
 )
 
-const Name = "discordo"
+const name = "discordo"
+
+type (
+	MessagesTextKeysConfig struct {
+		CopyContent string `yaml:"copy_content"`
+
+		Reply        string `yaml:"reply"`
+		ReplyMention string `yaml:"reply_mention"`
+		SelectReply  string `yaml:"select_reply"`
+
+		SelectPrevious string `yaml:"select_previous"`
+		SelectNext     string `yaml:"select_next"`
+		SelectFirst    string `yaml:"select_first"`
+		SelectLast     string `yaml:"select_last"`
+	}
+
+	MessageInputKeysConfig struct {
+		Send  string `yaml:"send"`
+		Paste string `yaml:"paste"`
+
+		LaunchEditor string `yaml:"launch_editor"`
+	}
+
+	KeysConfig struct {
+		Cancel string `yaml:"cancel"`
+
+		MessagesText MessagesTextKeysConfig `yaml:"messages_text"`
+		MessageInput MessageInputKeysConfig `yaml:"message_input"`
+	}
+)
+
+type (
+	GuildsTreeThemeConfig struct {
+		Graphics bool `yaml:"graphics"`
+	}
+
+	MessagesTextThemeConfig struct {
+		AuthorColor string `yaml:"author_color"`
+	}
+
+	MessageInputThemeConfig struct{}
+
+	ThemeConfig struct {
+		Border        bool   `yaml:"border"`
+		BorderColor   string `yaml:"border_color"`
+		BorderPadding [4]int `yaml:"border_padding,flow"`
+
+		TitleColor      string `yaml:"title_color"`
+		BackgroundColor string `yaml:"background_color"`
+
+		GuildsTree   GuildsTreeThemeConfig   `yaml:"guilds_tree"`
+		MessagesText MessagesTextThemeConfig `yaml:"messages_text"`
+		MessageInput MessageInputThemeConfig `yaml:"message_input"`
+	}
+)
 
 type Config struct {
 	Mouse         bool   `yaml:"mouse"`
@@ -19,13 +73,13 @@ type Config struct {
 	Theme ThemeConfig `yaml:"theme"`
 }
 
-func New() (*Config, error) {
+func newConfig() (*Config, error) {
 	path, err := os.UserConfigDir()
 	if err != nil {
 		return nil, err
 	}
 
-	path = filepath.Join(path, Name)
+	path = filepath.Join(path, name)
 	err = os.MkdirAll(path, os.ModePerm)
 	if err != nil {
 		return nil, err

+ 0 - 30
config/keys.go

@@ -1,30 +0,0 @@
-package config
-
-type (
-	MessagesTextKeysConfig struct {
-		CopyContent string `yaml:"copy_content"`
-
-		Reply        string `yaml:"reply"`
-		ReplyMention string `yaml:"reply_mention"`
-		SelectReply  string `yaml:"select_reply"`
-
-		SelectPrevious string `yaml:"select_previous"`
-		SelectNext     string `yaml:"select_next"`
-		SelectFirst    string `yaml:"select_first"`
-		SelectLast     string `yaml:"select_last"`
-	}
-
-	MessageInputKeysConfig struct {
-		Send  string `yaml:"send"`
-		Paste string `yaml:"paste"`
-
-		LaunchEditor string `yaml:"launch_editor"`
-	}
-
-	KeysConfig struct {
-		Cancel string `yaml:"cancel"`
-
-		MessagesText MessagesTextKeysConfig `yaml:"messages_text"`
-		MessageInput MessageInputKeysConfig `yaml:"message_input"`
-	}
-)

+ 0 - 26
config/theme.go

@@ -1,26 +0,0 @@
-package config
-
-type (
-	GuildsTreeThemeConfig struct {
-		Graphics bool `yaml:"graphics"`
-	}
-
-	MessagesTextThemeConfig struct {
-		AuthorColor string `yaml:"author_color"`
-	}
-
-	MessageInputThemeConfig struct{}
-
-	ThemeConfig struct {
-		Border        bool   `yaml:"border"`
-		BorderColor   string `yaml:"border_color"`
-		BorderPadding [4]int `yaml:"border_padding,flow"`
-
-		TitleColor      string `yaml:"title_color"`
-		BackgroundColor string `yaml:"background_color"`
-
-		GuildsTree   GuildsTreeThemeConfig   `yaml:"guilds_tree"`
-		MessagesText MessagesTextThemeConfig `yaml:"messages_text"`
-		MessageInput MessageInputThemeConfig `yaml:"message_input"`
-	}
-)

+ 5 - 6
main.go

@@ -7,7 +7,6 @@ import (
 	"os"
 	"path/filepath"
 
-	"github.com/ayn2op/discordo/config"
 	"github.com/rivo/tview"
 	"github.com/zalando/go-keyring"
 )
@@ -15,7 +14,7 @@ import (
 var (
 	token string
 
-	cfg          *config.Config
+	cfg          *Config
 	discordState *State
 
 	app  = tview.NewApplication()
@@ -34,7 +33,7 @@ func init() {
 		log.Fatal(err)
 	}
 
-	path = filepath.Join(path, config.Name)
+	path = filepath.Join(path, name)
 	err = os.MkdirAll(path, os.ModePerm)
 	if err != nil {
 		log.Fatal(err)
@@ -56,16 +55,16 @@ func main() {
 	var err error
 	// If the token is passed via the flag, set it in the keyring.
 	if token != "" {
-		go keyring.Set(config.Name, "token", token)
+		go keyring.Set(name, "token", token)
 	} else {
-		token, err = keyring.Get(config.Name, "token")
+		token, err = keyring.Get(name, "token")
 		if err != nil {
 			log.Println(err)
 			return
 		}
 	}
 
-	cfg, err = config.New()
+	cfg, err = newConfig()
 	if err != nil {
 		log.Fatal(err)
 	}

+ 2 - 3
state.go

@@ -5,7 +5,6 @@ import (
 	"log"
 	"runtime"
 
-	"github.com/ayn2op/discordo/config"
 	"github.com/diamondburned/arikawa/v3/api"
 	"github.com/diamondburned/arikawa/v3/gateway"
 	"github.com/diamondburned/arikawa/v3/state"
@@ -13,10 +12,10 @@ import (
 )
 
 func init() {
-	api.UserAgent = fmt.Sprintf("%s/%s %s/%s", config.Name, "0.1", "arikawa", "v3")
+	api.UserAgent = fmt.Sprintf("%s/%s %s/%s", name, "0.1", "arikawa", "v3")
 	gateway.DefaultIdentity = gateway.IdentifyProperties{
 		OS:      runtime.GOOS,
-		Browser: config.Name,
+		Browser: name,
 		Device:  "",
 	}
 }