Skip to content

Commit

Permalink
fix: log to file, improve styles
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Jul 15, 2021
1 parent eab6293 commit ef8a9d9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin
coverage.out
snap.login
completions/
*.log
6 changes: 6 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ Important notes:
csv = f
}

f, err := tea.LogToFile("org-stats.log", "org-stats")
if err != nil {
return err
}
defer f.Close()

p := tea.NewProgram(ui.NewInitialModel(
client,
organization,
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module github.com/caarlos0/org-stats

require (
github.com/caarlos0/duration v0.0.0-20210713014422-2153d649c037
github.com/caarlos0/spin v1.1.0
github.com/charmbracelet/bubbles v0.8.0
github.com/charmbracelet/bubbletea v0.14.1
github.com/charmbracelet/lipgloss v0.3.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/caarlos0/duration v0.0.0-20210713014422-2153d649c037 h1:Rn1A0df8CQZsO7hDvZGAVR06N6jqonCuj/K3IrGNZZY=
github.com/caarlos0/duration v0.0.0-20210713014422-2153d649c037/go.mod h1:mSkwb/eZEwOJJJ4tqAKiuhLIPe0e9+FKhlU0oMCpbf8=
github.com/caarlos0/spin v1.1.0 h1:EjsfGbZJejib25BPnDqf7iL2z9RUna7refvUf+AN9UE=
github.com/caarlos0/spin v1.1.0/go.mod h1:HOC4pUvfhjXR2yDt+sEY9dRc2m4CCaK5z5oQYAbzXSA=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/charmbracelet/bubbles v0.8.0 h1:+l2op90Ag37Vn+30O1hbg/0wBl+e+sxHhgY1F/rvdHs=
github.com/charmbracelet/bubbles v0.8.0/go.mod h1:5WX1sSSjNCgCrzvRMN/z23HxvWaa+AI16Ch0KPZPeDs=
Expand Down
18 changes: 11 additions & 7 deletions highlights/highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,21 @@ func Write(w io.Writer, s orgstats.Stats, top int, includeReviews bool) error {
Foreground(lipgloss.AdaptiveColor{
Dark: "#BD7EFC",
Light: "#7D56F4",
})
}).
MarginTop(1).
Underline(true)

var bodyStyle = lipgloss.NewStyle().
PaddingLeft(2)
MarginLeft(2)

var userStyle = lipgloss.NewStyle().Bold(true)

// TODO: handle no results for a given topic
for _, d := range data {
if _, err := fmt.Fprintln(w, headerStyle.Render(d.trophy+" champions are:")); err != nil {
if _, err := fmt.Fprintln(
w,
headerStyle.Render(d.trophy+" champions are:"),
); err != nil {
return err
}
j := top
Expand All @@ -58,7 +65,7 @@ func Write(w io.Writer, s orgstats.Stats, top int, includeReviews bool) error {
fmt.Sprintf(
"%s %s with %d %s!",
emojiForPos(i),
d.stats[i].Key,
userStyle.Render(d.stats[i].Key),
d.stats[i].Value,
d.kind,
),
Expand All @@ -67,9 +74,6 @@ func Write(w io.Writer, s orgstats.Stats, top int, includeReviews bool) error {
return err
}
}
if _, err := fmt.Fprintln(w); err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit ef8a9d9

Please sign in to comment.