Skip to content
This repository was archived by the owner on Jul 20, 2024. It is now read-only.

Commit 7898087

Browse files
authored
format all *.go files, update botway full docker image
1 parent 230559e commit 7898087

File tree

55 files changed

+982
-958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+982
-958
lines changed

constants/constants.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,57 @@ import (
1212
var (
1313
// Styles
1414
PRIMARY_COLOR_HEX = "#1E90FF"
15-
PRIMARY_COLOR = lipgloss.Color(PRIMARY_COLOR_HEX)
16-
CYAN_COLOR = lipgloss.Color("#00FFFF")
17-
GREEN_COLOR = "#04B575"
18-
RED_COLOR = "#FF4141"
19-
YELLOW_COLOR = lipgloss.Color("178")
20-
GRAY_COLOR = lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}
15+
PRIMARY_COLOR = lipgloss.Color(PRIMARY_COLOR_HEX)
16+
CYAN_COLOR = lipgloss.Color("#00FFFF")
17+
GREEN_COLOR = "#04B575"
18+
RED_COLOR = "#FF4141"
19+
YELLOW_COLOR = lipgloss.Color("178")
20+
GRAY_COLOR = lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}
2121

2222
BOLD = lipgloss.NewStyle().Bold(true)
2323

24-
SUCCESS_BACKGROUND = lipgloss.NewStyle().
25-
Bold(true).
26-
Foreground(lipgloss.Color("#FFF")).
27-
Background(lipgloss.Color(GREEN_COLOR)).
28-
PaddingLeft(1).
29-
PaddingRight(1)
24+
SUCCESS_BACKGROUND = lipgloss.NewStyle().
25+
Bold(true).
26+
Foreground(lipgloss.Color("#FFF")).
27+
Background(lipgloss.Color(GREEN_COLOR)).
28+
PaddingLeft(1).
29+
PaddingRight(1)
3030
FAIL_BACKGROUND = lipgloss.NewStyle().
31-
Bold(true).
32-
Foreground(lipgloss.Color("#FFF")).
33-
Background(lipgloss.Color(RED_COLOR)).
34-
PaddingLeft(1).
35-
PaddingRight(1)
31+
Bold(true).
32+
Foreground(lipgloss.Color("#FFF")).
33+
Background(lipgloss.Color(RED_COLOR)).
34+
PaddingLeft(1).
35+
PaddingRight(1)
3636
INFO_BACKGROUND = lipgloss.NewStyle().
37-
Bold(true).
38-
Foreground(lipgloss.Color("#FFF")).
39-
Background(lipgloss.Color(CYAN_COLOR)).
40-
PaddingLeft(1).
41-
PaddingRight(1)
37+
Bold(true).
38+
Foreground(lipgloss.Color("#FFF")).
39+
Background(lipgloss.Color(CYAN_COLOR)).
40+
PaddingLeft(1).
41+
PaddingRight(1)
4242
WARN_BACKGROUND = lipgloss.NewStyle().
43-
Bold(true).
44-
Foreground(lipgloss.Color("#FFF")).
45-
Background(lipgloss.Color(YELLOW_COLOR)).
46-
PaddingLeft(1).
47-
PaddingRight(1)
43+
Bold(true).
44+
Foreground(lipgloss.Color("#FFF")).
45+
Background(lipgloss.Color(YELLOW_COLOR)).
46+
PaddingLeft(1).
47+
PaddingRight(1)
4848
PRIMARY_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(PRIMARY_COLOR)
4949
SUCCESS_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(GREEN_COLOR))
50-
FAIL_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(RED_COLOR))
51-
INFO_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(CYAN_COLOR))
50+
FAIL_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(RED_COLOR))
51+
INFO_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(CYAN_COLOR))
5252
COMMAND_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(GRAY_COLOR)
53-
WARN_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(YELLOW_COLOR))
53+
WARN_FOREGROUND = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(YELLOW_COLOR))
5454

5555
// File Paths
56-
HomeDir, _ = dfs.GetHomeDirectory()
57-
BotwayConfigFile = filepath.Join(HomeDir, ".botway", "botway.json")
56+
HomeDir, _ = dfs.GetHomeDirectory()
57+
BotwayConfigFile = filepath.Join(HomeDir, ".botway", "botway.json")
5858
BotwayConfig, Berr = ioutil.ReadFile(BotwayConfigFile)
59-
BotConfig, Oerr = ioutil.ReadFile(".botway.yaml")
60-
Guilds, Gerr = ioutil.ReadFile(filepath.Join("config", "guilds.json"))
59+
BotConfig, Oerr = ioutil.ReadFile(".botway.yaml")
60+
Guilds, Gerr = ioutil.ReadFile(filepath.Join("config", "guilds.json"))
6161

62-
RailwayConfigFile = filepath.Join(HomeDir, ".railway", "config.json")
62+
RailwayConfigFile = filepath.Join(HomeDir, ".railway", "config.json")
6363
RailwayConfig, Rerr = ioutil.ReadFile(RailwayConfigFile)
6464

65-
BotwayDirPath = func () string {
65+
BotwayDirPath = func() string {
6666
if runtime.GOOS == "windows" {
6767
return `$HOME\\.botway`
6868
} else {

docker/full.dockerfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
FROM frolvlad/alpine-glibc:alpine-3.14_glibc-2.33
22

33
### variables ###
4-
ENV PKGS="zip unzip git curl npm rust py3-pip openssl openssl-dev libsodium ffmpeg cargo lld clang build-base abuild binutils opus autoconf automake libtool m4 youtube-dl binutils-doc gcc-doc python3-dev neofetch zsh sudo make lsof wget gcc asciidoctor ca-certificates bash-completion htop jq less llvm nano vim ruby-full ruby-dev libffi-dev"
4+
ENV PKGS="zip unzip git curl npm py3-pip openssl openssl-dev libsodium ffmpeg lld clang build-base abuild binutils opus autoconf automake libtool m4 youtube-dl binutils-doc gcc-doc python3-dev neofetch zsh sudo make lsof wget gcc asciidoctor ca-certificates bash-completion htop jq less llvm nano vim ruby-full ruby-dev libffi-dev"
55
ENV ZSHRC=".zshrc"
66

77
### install packages ###
88
RUN apk upgrade && \
99
apk add --update $PKGS
1010

11+
ENV RUSTUP_HOME=/usr/local/rustup \
12+
CARGO_HOME=/usr/local/cargo \
13+
PATH=/usr/local/cargo/bin:$PATH
14+
15+
RUN set -eux; \
16+
apkArch="$(apk --print-arch)"; \
17+
case "$apkArch" in \
18+
x86_64) rustArch='x86_64-unknown-linux-musl' ;; \
19+
aarch64) rustArch='aarch64-unknown-linux-musl' ;; \
20+
*) echo >&2 "unsupported architecture: $apkArch"; exit 1 ;; \
21+
esac; \
22+
\
23+
url="https://static.rust-lang.org/rustup/dist/${rustArch}/rustup-init"; \
24+
wget "$url"; \
25+
chmod +x rustup-init; \
26+
./rustup-init -y --no-modify-path --default-toolchain nightly; \
27+
rm rustup-init; \
28+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
29+
rustup --version; \
30+
cargo --version; \
31+
rustc --version;
32+
1133
### setup user ###
1234
USER root
1335
RUN adduser -D bw \
@@ -55,7 +77,7 @@ RUN sudo mv "gh_$(curl https://get-latest.herokuapp.com/cli/cli/no-v)_linux_amd6
5577
RUN rm -rf gh*
5678

5779
### fleet ###
58-
RUN curl -L get.fleet.rs | sh
80+
RUN cargo install fleet-rs
5981

6082
### pyenv ###
6183
RUN pip install tld --ignore-installed six distlib --user

internal/checker/checker.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ func Check(buildVersion string) {
3636

3737
if buildVersion != latestVersion {
3838
fmt.Fprintf(stderr, "\n%s %s → %s",
39-
constants.WARN_FOREGROUND.Render("There's a new version of ") +
40-
constants.PRIMARY_FOREGROUND.Render("botway") +
41-
constants.WARN_FOREGROUND.Render(" is avalaible:"),
39+
constants.WARN_FOREGROUND.Render("There's a new version of ")+
40+
constants.PRIMARY_FOREGROUND.Render("botway")+
41+
constants.WARN_FOREGROUND.Render(" is avalaible:"),
4242
constants.PRIMARY_FOREGROUND.Render(buildVersion),
43-
constants.PRIMARY_FOREGROUND.Render(latestVersion) +
44-
"\n",
43+
constants.PRIMARY_FOREGROUND.Render(latestVersion)+
44+
"\n",
4545
)
4646

4747
if command() != "" {
48-
fmt.Fprintf(stderr, constants.WARN_FOREGROUND.Render("To upgrade, run: %s"), constants.COMMAND_FOREGROUND.Render(command()) + "\n")
48+
fmt.Fprintf(stderr, constants.WARN_FOREGROUND.Render("To upgrade, run: %s"), constants.COMMAND_FOREGROUND.Render(command())+"\n")
4949
}
5050
}
5151
}

internal/dashboard/bots.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
var (
9-
bots = gjson.Get(string(constants.BotwayConfig), "botway.bots_names")
9+
bots = gjson.Get(string(constants.BotwayConfig), "botway.bots_names")
1010
bots_count = gjson.Get(string(constants.BotwayConfig), "botway.bots_names.#").Int()
1111
)
1212

@@ -21,7 +21,7 @@ func (b Bubble) botInfo(infoToGet string) string {
2121
return true
2222
})
2323

24-
bot := gjson.Get(string(constants.BotwayConfig), "botway.bots." + v)
24+
bot := gjson.Get(string(constants.BotwayConfig), "botway.bots."+v)
2525

2626
if infoToGet == "token" {
2727
return gjson.Get(bot.String(), "bot_token").String()

internal/dashboard/components/constants.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const (
44
MinWidth = 115
55
MinHeight = 20
66

7-
CommandView = 0
8-
BotListView = 1
9-
BotInfoView = 2
7+
CommandView = 0
8+
BotListView = 1
9+
BotInfoView = 2
1010

1111
StatusBarHeight = 1
12-
BoxPadding = 1
12+
BoxPadding = 1
1313

1414
EllipsisStyle = "..."
1515
)

internal/dashboard/components/keymap/keymap.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package keymap
33
import "github.com/charmbracelet/bubbles/key"
44

55
type KeyMap struct {
6-
Quit key.Binding
7-
Down key.Binding
8-
Up key.Binding
9-
Left key.Binding
10-
Right key.Binding
11-
Esc key.Binding
12-
SwapView key.Binding
6+
Quit key.Binding
7+
Down key.Binding
8+
Up key.Binding
9+
Left key.Binding
10+
Right key.Binding
11+
Esc key.Binding
12+
SwapView key.Binding
1313
OpenAtRailway key.Binding
1414
PageDown key.Binding
1515
PageUp key.Binding

internal/dashboard/components/style/style.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ var (
4545
PaginatorInactiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "250", Dark: "238"}).Render("•")
4646

4747
ListSelected = lipgloss.NewStyle().
48-
Background(theme.AppTheme.SelectedListItemColor).
49-
Foreground(theme.AppTheme.UnselectedListItemColor)
48+
Background(theme.AppTheme.SelectedListItemColor).
49+
Foreground(theme.AppTheme.UnselectedListItemColor)
5050

5151
AbstractInfo = lipgloss.NewStyle().
52-
Bold(false).
53-
Align(lipgloss.Center).
54-
Height(3).
55-
Padding(1, 2)
52+
Bold(false).
53+
Align(lipgloss.Center).
54+
Height(3).
55+
Padding(1, 2)
5656

5757
KeyStyle = lipgloss.NewStyle().
5858
Align(lipgloss.Left).
@@ -64,5 +64,5 @@ var (
6464
Padding(0, 2)
6565

6666
StatusBar = lipgloss.NewStyle().
67-
Height(components.StatusBarHeight)
67+
Height(components.StatusBarHeight)
6868
)

internal/dashboard/components/viewport/viewport.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (m *Viewport) HalfViewDown() (lines []string) {
137137
return nil
138138
}
139139

140-
m.SetYOffset(m.YOffset + m.Height / 2)
140+
m.SetYOffset(m.YOffset + m.Height/2)
141141

142142
return m.visibleLines()
143143
}
@@ -147,7 +147,7 @@ func (m *Viewport) HalfViewUp() (lines []string) {
147147
return nil
148148
}
149149

150-
m.SetYOffset(m.YOffset - m.Height / 2)
150+
m.SetYOffset(m.YOffset - m.Height/2)
151151

152152
return m.visibleLines()
153153
}
@@ -223,32 +223,32 @@ func (m Viewport) updateAsModel(msg tea.Msg) (Viewport, tea.Cmd) {
223223
var cmd tea.Cmd
224224

225225
switch msg := msg.(type) {
226-
case tea.KeyMsg:
227-
switch {
228-
case key.Matches(msg, m.KeyMap.PageDown):
229-
m.ViewDown()
226+
case tea.KeyMsg:
227+
switch {
228+
case key.Matches(msg, m.KeyMap.PageDown):
229+
m.ViewDown()
230230

231-
case key.Matches(msg, m.KeyMap.PageUp):
232-
m.ViewUp()
231+
case key.Matches(msg, m.KeyMap.PageUp):
232+
m.ViewUp()
233233

234-
case key.Matches(msg, m.KeyMap.Down):
235-
m.LineDown(1)
234+
case key.Matches(msg, m.KeyMap.Down):
235+
m.LineDown(1)
236236

237-
case key.Matches(msg, m.KeyMap.Up):
238-
m.LineUp(1)
239-
}
237+
case key.Matches(msg, m.KeyMap.Up):
238+
m.LineUp(1)
239+
}
240240

241241
case tea.MouseMsg:
242242
if !m.MouseWheelEnabled {
243243
break
244244
}
245245

246246
switch msg.Type {
247-
case tea.MouseWheelUp:
248-
m.LineUp(m.MouseWheelDelta)
247+
case tea.MouseWheelUp:
248+
m.LineUp(m.MouseWheelDelta)
249249

250-
case tea.MouseWheelDown:
251-
m.LineDown(m.MouseWheelDelta)
250+
case tea.MouseWheelDown:
251+
m.LineDown(m.MouseWheelDelta)
252252
}
253253
}
254254

internal/dashboard/dash.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
type ErrorMsg error
1212

1313
type Bubble struct {
14-
bubbles Bubbles
15-
keyMap keymap.KeyMap
16-
nav Nav
17-
ready bool
18-
activeBox int
19-
lastActiveBox int
20-
width int
21-
height int
14+
bubbles Bubbles
15+
keyMap keymap.KeyMap
16+
nav Nav
17+
ready bool
18+
activeBox int
19+
lastActiveBox int
20+
width int
21+
height int
2222
}
2323

2424
type Bubbles struct {
@@ -60,11 +60,11 @@ func InitialModel() Bubble {
6060
}
6161

6262
return Bubble{
63-
bubbles: bubs,
64-
ready: false,
65-
nav: nav,
66-
activeBox: components.BotListView,
67-
keyMap: keymap.New(),
63+
bubbles: bubs,
64+
ready: false,
65+
nav: nav,
66+
activeBox: components.BotListView,
67+
keyMap: keymap.New(),
6868
}
6969
}
7070

internal/dashboard/icons/glyph.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package icons
55
import "fmt"
66

77
type IconInfo struct {
8-
icon string
9-
color [3]uint8
8+
icon string
9+
color [3]uint8
1010
}
1111

1212
func (i *IconInfo) GetGlyph() string {

0 commit comments

Comments
 (0)