Skip to content

Commit 77da4cf

Browse files
committed
feat: add Homebrew formula configuration and version flag to dotcat CLI
- Introduced Homebrew formula configuration in .goreleaser.yml for easier installation and management of the dotcat CLI. - Added version information display in the CLI, allowing users to check the current version, commit, and build date. - Enhanced command-line flags to include a version flag for improved user experience.
1 parent a5e6d2a commit 77da4cf

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.goreleaser.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ changelog:
4646
- "Merge pull request"
4747
- "Merge branch"
4848

49+
brews:
50+
- name: "{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}"
51+
repository:
52+
owner: adebert
53+
name: homebrew-tools
54+
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
55+
directory: "Formula"
56+
commit_author:
57+
name: goreleaserbot
58+
email: bot@goreleaser.com
59+
homepage: "https://github.com/adebert/dotcat"
60+
description: "A CLI utility for reading values from structured data files."
61+
license: "MIT"
62+
test: |
63+
system "#{bin}/{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }} --version"
64+
install: |
65+
bin.install "{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}"
66+
man1.install "man/man1/{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}.1"
67+
bash_completion.install "completions/{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}.bash" => "{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}"
68+
zsh_completion.install "completions/_{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}" => "_{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}"
69+
fish_completion.install "completions/{{ if .Env.PKG_NAME }}{{ .Env.PKG_NAME }}{{ else }}dotcat{{ end }}.fish"
70+
4971
# nFPM packages (deb, rpm, etc.)
5072
# https://goreleaser.com/customization/nfpm/
5173
nfpms:

cmd/app/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,28 @@ import (
1010
"github.com/adebert/dotcat/internal/formatter"
1111
)
1212

13+
// Version information - will be set during build
14+
var (
15+
version = "dev"
16+
commit = "none"
17+
date = "unknown"
18+
)
19+
1320
var outputFormat string
21+
var showVersion bool
1422

1523
var rootCmd = &cobra.Command{
1624
Use: "dotcat [file] [dotted_path]",
1725
Short: "Get a value from a structured data file using a dotted path",
1826
Long: `dotcat allows you to read a value from a structured data file
1927
(JSON, YAML, TOML, or INI) using a dot-separated path to the desired key.`,
2028
RunE: func(cmd *cobra.Command, args []string) error {
29+
// If version flag is provided, print version and exit
30+
if showVersion {
31+
fmt.Printf("dotcat version %s, commit %s, built at %s\n", version, commit, date)
32+
return nil
33+
}
34+
2135
if len(args) != 2 {
2236
fmt.Println("Usage: ")
2337
fmt.Println("dotcat <file> <variable path> ")
@@ -52,6 +66,7 @@ var rootCmd = &cobra.Command{
5266

5367
func init() {
5468
rootCmd.Flags().StringVarP(&outputFormat, "output", "o", "raw", "Output format (raw, json, yaml, toml, ini)")
69+
rootCmd.Flags().BoolVarP(&showVersion, "version", "v", false, "Show version information")
5570
}
5671

5772
func main() {

0 commit comments

Comments
 (0)