Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(build): update version cmd to return build info instead of static version #42

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include .bingo/Variables.mk
export GIT_VERSION ?= $(shell git describe --tags --always --dirty)
export VERSION_PKG ?= $(shell go list -m)/internal/cli
export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
export GO_BUILD_LDFLAGS ?= -s -w -X "$(VERSION_PKG).version=$(GIT_VERSION)"
export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}

export IMAGE_REPO ?= docker.io/bpalmer/buoy
Expand All @@ -12,9 +11,8 @@ export IMAGE_TAG ?= devel
build:
go build \
-asmflags '$(GO_BUILD_ASMFLAGS)' \
-ldflags '$(GO_BUILD_LDFLAGS)' \
-gcflags '$(GO_BUILD_GCFLAGS)' \
-o buoy main.go
-o buoy .

export ENABLE_RELEASE_PIPELINE ?= false
export GORELEASER_ARGS ?= --snapshot --clean
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/charmbracelet/bubbles v0.16.1
github.com/charmbracelet/bubbletea v0.24.2
github.com/charmbracelet/lipgloss v0.7.1
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be
github.com/sahilm/fuzzy v0.1.0
github.com/spf13/cobra v1.7.0
github.com/tidwall/gjson v1.17.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ github.com/charmbracelet/bubbletea v0.24.2 h1:uaQIKx9Ai6Gdh5zpTbGiWpytMU+CfsPp06
github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FDaJmO3l2nejekbsgg=
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ=
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down
26 changes: 23 additions & 3 deletions internal/cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,36 @@ package cli

import (
"fmt"
"runtime/debug"
"strings"

"github.com/charmbracelet/lipgloss"
figure "github.com/common-nighthawk/go-figure"
"github.com/everettraven/buoy/pkg/charm/styles"
"github.com/spf13/cobra"
)

var version = "unknown"

var versionCommand = &cobra.Command{
Use: "version",
Short: "installed version of buoy",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("buoy", version)
var out strings.Builder
fig := figure.NewFigure("buoy", "rounded", true)
header := lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, true).
BorderForeground(styles.DefaultColor).
Render(fig.String())

out.WriteString(header + "\n\n")
settingNameStyle := lipgloss.NewStyle().Bold(true)
if bi, ok := debug.ReadBuildInfo(); ok {
for _, setting := range bi.Settings {
name := settingNameStyle.Render(setting.Key)
out.WriteString(fmt.Sprintf("%s: %s\n", name, setting.Value))
}
} else {
out.WriteString("unable to read build info")
}
fmt.Print(out.String())
},
}
12 changes: 6 additions & 6 deletions pkg/charm/styles/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ package styles

import "github.com/charmbracelet/lipgloss"

var adaptColor = lipgloss.AdaptiveColor{Light: "63", Dark: "117"}
var DefaultColor = lipgloss.AdaptiveColor{Light: "63", Dark: "117"}

func SelectedTabStyle() lipgloss.Style {
border := lipgloss.RoundedBorder()
border.BottomLeft = "┘"
border.Bottom = " "
border.BottomRight = "└"
return lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Border(border).BorderForeground(adaptColor).Padding(0, 1)
return lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Border(border).BorderForeground(DefaultColor).Padding(0, 1)
}

func TabStyle() lipgloss.Style {
border := lipgloss.RoundedBorder()
border.BottomLeft = "┴"
border.BottomRight = "┴"
return lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Border(border).BorderForeground(adaptColor).Padding(0, 1)
return lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Border(border).BorderForeground(DefaultColor).Padding(0, 1)
}

func TabGap() lipgloss.Style {
border := lipgloss.RoundedBorder()
return lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Border(border, false, false, true, false).BorderForeground(adaptColor).Padding(0, 1)
return lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Border(border, false, false, true, false).BorderForeground(DefaultColor).Padding(0, 1)
}

func ContentStyle() lipgloss.Style {
return lipgloss.NewStyle().Align(lipgloss.Center, lipgloss.Center)
}

func TableSelectedRowStyle() lipgloss.Style {
return lipgloss.NewStyle().Foreground(adaptColor)
return lipgloss.NewStyle().Foreground(DefaultColor)
}

func LogSearchHighlightStyle() lipgloss.Style {
return lipgloss.NewStyle().Foreground(adaptColor)
return lipgloss.NewStyle().Foreground(DefaultColor)
}

func LogSearchModeStyle() lipgloss.Style {
Expand Down
Loading