From 99922c258252d8daddeb03199e599a29dc032e7c Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 26 Oct 2019 21:24:41 -0400 Subject: [PATCH] Update config to be more uniform --- defaultConfig.go | 17 +++++++++-------- kbtui.toml | 19 ++++++++++--------- types.go | 37 ++++++++++++++++++++++--------------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/defaultConfig.go b/defaultConfig.go index 4d406a5..88d1b3e 100644 --- a/defaultConfig.go +++ b/defaultConfig.go @@ -2,23 +2,24 @@ package main var defaultConfig = ` [basics] -downloadPath = "/tmp/" +download_path = "/tmp/" colorless = false + # The prefix before evaluating a command -cmdPrefix = "/" +cmd_prefix = "/" [formatting] # BASH-like PS1 variable equivalent -outputFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" -outputStreamFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" -outputMentionFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" -pmFormat = "PM from $USER@$DEVICE: $MSG" +output_format = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" +output_stream_format = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" +output_mention_format = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" +pm_format = "PM from $USER@$DEVICE: $MSG" # 02 = Day, Jan = Month, 06 = Year -dateFormat = "02Jan06" +date_format = "02Jan06" # 15 = hours, 04 = minutes, 05 = seconds -timeFormat = "15:04" +time_format = "15:04" [colors] diff --git a/kbtui.toml b/kbtui.toml index 290b742..6196e2e 100644 --- a/kbtui.toml +++ b/kbtui.toml @@ -1,21 +1,22 @@ [basics] -downloadPath = "/tmp/" +download_path = "/tmp/" colorless = false + # The prefix before evaluating a command -cmdPrefix = "/" +cmd_prefix = "/" [formatting] # BASH-like PS1 variable equivalent -outputFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" -outputStreamFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" -outputMentionFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" -pmFormat = "PM from $USER@$DEVICE: $MSG" +output_format = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" +output_stream_format = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" +output_mention_format = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" +pm_format = "PM from $USER@$DEVICE: $MSG" # 02 = Day, Jan = Month, 06 = Year -dateFormat = "02Jan06" +date_format = "02Jan06" # 15 = hours, 04 = minutes, 05 = seconds -timeFormat = "15:04" +time_format = "15:04" [colors] @@ -63,4 +64,4 @@ timeFormat = "15:04" [colors.feed.basic] foreground = "grey" [colors.feed.error] - foreground = "red" \ No newline at end of file + foreground = "red" diff --git a/types.go b/types.go index b8fd72f..744a14a 100644 --- a/types.go +++ b/types.go @@ -20,27 +20,37 @@ type TypeCommand struct { // Config holds user-configurable values type Config struct { - filepath string `toml:"-"` + filepath string `toml:"-"` // filepath is not stored in the config file, but is written to the Config struct so it's known where the config was loaded from Basics Basics `toml:"basics"` Formatting Formatting `toml:"formatting"` Colors Colors `toml:"colors"` } +// Basics holds the 'basics' section of the config file type Basics struct { - DownloadPath string `toml:"downloadPath"` + DownloadPath string `toml:"download_path"` Colorless bool `toml:"colorless"` - CmdPrefix string `toml:"cmdPrefix"` + CmdPrefix string `toml:"cmd_prefix"` } +// Formatting holds the 'formatting' section of the config file type Formatting struct { - OutputFormat string `toml:"outputFormat"` - OutputStreamFormat string `toml:"outputStreamFormat"` - OutputMentionFormat string `toml:"outputMentionFormat"` - PMFormat string `toml:"pmFormat"` - DateFormat string `toml:"dateFormat"` - TimeFormat string `toml:"timeFormat"` + OutputFormat string `toml:"output_format"` + OutputStreamFormat string `toml:"output_stream_format"` + OutputMentionFormat string `toml:"output_mention_format"` + PMFormat string `toml:"pm_format"` + DateFormat string `toml:"date_format"` + TimeFormat string `toml:"time_format"` } +// Colors holds the 'colors' section of the config file +type Colors struct { + Channels Channels `toml:"channels"` + Message Message `toml:"message"` + Feed Feed `toml:"feed"` +} + +// Style holds basic style information type Style struct { Foreground string `toml:"foreground"` Background string `toml:"background"` @@ -51,12 +61,14 @@ type Style struct { Inverse bool `toml:"inverse"` } +// Channels holds the style information for various elements of a channel type Channels struct { Basic Style `toml:"basic"` Header Style `toml:"header"` Unread Style `toml:"unread"` } +// Message holds the style information for various elements of a message type Message struct { Body Style `toml:"body"` Header Style `toml:"header"` @@ -72,13 +84,8 @@ type Message struct { Code Style `toml:"code"` } +// Feed holds the style information for various elements of the feed window type Feed struct { Basic Style `toml:"basic"` Error Style `toml:"error"` } - -type Colors struct { - Channels Channels `toml:"channels"` - Message Message `toml:"message"` - Feed Feed `toml:"feed"` -}