feat: add Homebrew and Scoop publishing scripts, enhance versioning metadata
This commit is contained in:
+5
-4
@@ -91,11 +91,12 @@ func bootstrap(cmd *cli.Command) (*App, error) {
|
||||
// First-run UX: if there is genuinely no config yet, an interactive
|
||||
// session gets an inline wizard instead of a wall of "no profile
|
||||
// configured" errors — but never for `config ...` itself (that
|
||||
// subtree has its own explicit `init`) and never in a non-interactive
|
||||
// context (CI, pipes), where the tool must stay driven entirely by
|
||||
// flags/env instead of blocking on stdin.
|
||||
// subtree has its own explicit `init`), never for `version` (which
|
||||
// shouldn't need a Vault connection at all), and never in a
|
||||
// non-interactive context (CI, pipes), where the tool must stay
|
||||
// driven entirely by flags/env instead of blocking on stdin.
|
||||
leaf := cmd.Args().First()
|
||||
if !config.Exists(path) && IsInteractive() && leaf != "config" {
|
||||
if !config.Exists(path) && IsInteractive() && leaf != "config" && leaf != "version" {
|
||||
if _, err := runWizard(path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,11 +9,12 @@ import (
|
||||
// Root builds the full command tree. DefaultCommand launches the TUI when
|
||||
// vault-tui is invoked with no subcommand, matching the plan's "possible
|
||||
// without any subcommand" requirement.
|
||||
func Root(version string) *cli.Command {
|
||||
func Root(b BuildInfo) *cli.Command {
|
||||
build = b
|
||||
root := &cli.Command{
|
||||
Name: "vault-tui",
|
||||
Usage: "Terminal UI for HashiCorp Vault",
|
||||
Version: version,
|
||||
Version: b.Version,
|
||||
DefaultCommand: "ui",
|
||||
// Deliberately no Sources: cli.EnvVars(...) here: internal/config.Resolve
|
||||
// (and config.ResolvePath/SelectProfile for --config/--profile) already
|
||||
@@ -49,6 +50,7 @@ func Root(version string) *cli.Command {
|
||||
loginCommand(),
|
||||
logoutCommand(),
|
||||
statusCommand(),
|
||||
versionCommand(),
|
||||
listCommand(),
|
||||
readCommand(),
|
||||
writeCommand(),
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
// BuildInfo carries version metadata baked in at build time via -ldflags
|
||||
// (see the Makefile's LDFLAGS/PRERELEASE variables and the release Gitea
|
||||
// Actions workflow, which sets PRERELEASE from the triggering release's
|
||||
// "prerelease" flag). Root stores the value it was given so versionCommand
|
||||
// and internal/ui's footer (via Build) can read it back without threading
|
||||
// it through every call site.
|
||||
type BuildInfo struct {
|
||||
Version string // git tag (or "dev" for untagged/local builds)
|
||||
Commit string
|
||||
Date string
|
||||
Prerelease bool
|
||||
}
|
||||
|
||||
var build BuildInfo
|
||||
|
||||
// Build returns the BuildInfo Root was constructed with.
|
||||
func Build() BuildInfo { return build }
|
||||
|
||||
// String renders "1.2.3 (commit abc1234, built 2026-08-14T12:00:00Z)",
|
||||
// appending " [prerelease]" when the triggering Gitea release was marked
|
||||
// as a prerelease.
|
||||
func (b BuildInfo) String() string {
|
||||
s := fmt.Sprintf("%s (commit %s, built %s)", valueOr(b.Version, "dev"), valueOr(b.Commit, "none"), valueOr(b.Date, "unknown"))
|
||||
if b.Prerelease {
|
||||
s += " [prerelease]"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// versionCommand prints build metadata. Unlike every other command it does
|
||||
// not touch a.Client/a.Store — see bootstrap's leaf-skip check, which keeps
|
||||
// `vault-tui version` from tripping the first-run config wizard.
|
||||
func versionCommand() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "print version, commit, build date, and prerelease status",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{Name: "json"},
|
||||
},
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
b := Build()
|
||||
if cmd.Bool("json") {
|
||||
return printJSON(os.Stdout, map[string]any{
|
||||
"version": b.Version,
|
||||
"commit": b.Commit,
|
||||
"date": b.Date,
|
||||
"prerelease": b.Prerelease,
|
||||
})
|
||||
}
|
||||
fmt.Println(b.String())
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"charm.land/bubbles/v2/help"
|
||||
"charm.land/bubbles/v2/key"
|
||||
"charm.land/lipgloss/v2"
|
||||
|
||||
"git.morlana.online/f.weber/vault-tui/internal/cli"
|
||||
)
|
||||
|
||||
// screenHelp is the shape every keys.KeyMap.XxxHelp() screen-help value
|
||||
@@ -156,7 +158,12 @@ func (m *Model) viewHeader() string {
|
||||
// status line (profile/address, or the current toast) — one line total on
|
||||
// sizeTiny, two otherwise.
|
||||
func (m *Model) viewFooter(sh screenHelp) string {
|
||||
status := fmt.Sprintf("%s @ %s", m.a.Settings.Profile, m.a.Settings.Address)
|
||||
b := cli.Build()
|
||||
ver := b.Version
|
||||
if b.Prerelease {
|
||||
ver += " (prerelease)"
|
||||
}
|
||||
status := fmt.Sprintf("%s @ %s · %s", m.a.Settings.Profile, m.a.Settings.Address, ver)
|
||||
if toastStr := m.toastView(); toastStr != "" {
|
||||
status = toastStr
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user