Skip to content
Closed
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
14 changes: 14 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Dear Agent

This is a CLI tool for the Honeycomb.io API, written in Go.

## Structure

- `main.go` - entry point
- `cmd/` - cobra command definitions (root, version, etc.)
- `honeycomb/` - API client package

## Install

```shell
go install github.com/maragudk/honeycomb-cli@latest
```
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# template
# honeycomb-cli

[![Docs](https://pkg.go.dev/badge/maragu.dev/template)](https://pkg.go.dev/maragu.dev/template)
[![CI](https://github.com/maragudk/template/actions/workflows/ci.yml/badge.svg)](https://github.com/maragudk/template/actions/workflows/ci.yml)
[![CI](https://github.com/maragudk/honeycomb-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/maragudk/honeycomb-cli/actions/workflows/ci.yml)

Made with ✨sparkles✨ by [maragu](https://www.maragu.dev/): independent software consulting for cloud-native Go apps & AI engineering.
A command-line interface for the [Honeycomb.io](https://www.honeycomb.io/) observability platform.

[Contact me at markus@maragu.dk](mailto:markus@maragu.dk) for consulting work, or perhaps an invoice to support this project?
Made with sparkles by [maragu](https://www.maragu.dev/).

## Install

```shell
go install github.com/maragudk/honeycomb-cli@latest
```

## Usage

```shell
# Set your API key
export HONEYCOMB_API_KEY=your-api-key

# Or pass it as a flag
honeycomb-cli --api-key your-api-key <command>

# Verify your API key
honeycomb-cli auth
```
49 changes: 49 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "honeycomb-cli",
Short: "A CLI for the Honeycomb.io API",
Long: "A command-line interface for interacting with the Honeycomb.io observability platform.",
}

// Execute the root command and return an exit code.
func Execute() int {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
return 0
}

func init() {
rootCmd.PersistentFlags().String("api-key", "", "Honeycomb API key (or set HONEYCOMB_API_KEY)")
rootCmd.PersistentFlags().String("api-url", "https://api.honeycomb.io", "Honeycomb API URL (or set HONEYCOMB_API_URL)")
}

// apiKey returns the API key from the flag or environment variable.
func apiKey(cmd *cobra.Command) string {

Check failure on line 31 in cmd/root.go

View workflow job for this annotation

GitHub Actions / Lint

func apiKey is unused (unused)
key, _ := cmd.Flags().GetString("api-key")
if key != "" {
return key
}
return os.Getenv("HONEYCOMB_API_KEY")
}

// apiURL returns the API URL from the flag or environment variable.
func apiURL(cmd *cobra.Command) string {

Check failure on line 40 in cmd/root.go

View workflow job for this annotation

GitHub Actions / Lint

func apiURL is unused (unused)
url, _ := cmd.Flags().GetString("api-url")
if url != "https://api.honeycomb.io" {
return url
}
if envURL := os.Getenv("HONEYCOMB_API_URL"); envURL != "" {
return envURL
}
return url
}
16 changes: 16 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cmd_test

import (
"testing"

"maragu.dev/is"

"github.com/maragudk/honeycomb-cli/cmd"
)

func TestExecute(t *testing.T) {
t.Run("returns 0 on success", func(t *testing.T) {
code := cmd.Execute()
is.Equal(t, 0, code)
})
}
20 changes: 20 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// version is set at build time via -ldflags.
var version = "dev"

func init() {
rootCmd.AddCommand(&cobra.Command{
Use: "version",
Short: "Print the version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
})
}
12 changes: 11 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
module maragu.dev/template
module github.com/maragudk/honeycomb-cli

go 1.26

require (
github.com/spf13/cobra v1.10.2
maragu.dev/is v0.3.1
)

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.9 // indirect
)
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
maragu.dev/is v0.3.1 h1:1sj4Ewc9Ecqtvp1Aro+kRCpnuu4D5CB8w//GOfM7jFs=
maragu.dev/is v0.3.1/go.mod h1:bviaM5S0fBshCw7wuumFGTju/izopZ/Yvq4g7Klc7y8=
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"os"

"github.com/maragudk/honeycomb-cli/cmd"
)

func main() {
os.Exit(cmd.Execute())
}
1 change: 0 additions & 1 deletion template.go

This file was deleted.

Loading