Skip to content
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
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ BINARY=powerctl
# Build directory
DIST=dist

# Version (from git tag or commit)
# Version info
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT=$(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)

# Build flags
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
LDFLAGS=-ldflags "-s -w \
-X github.com/kristofferrisa/powerctl-cli/internal/commands.Version=$(VERSION) \
-X github.com/kristofferrisa/powerctl-cli/internal/commands.GitCommit=$(GIT_COMMIT) \
-X github.com/kristofferrisa/powerctl-cli/internal/commands.BuildDate=$(BUILD_DATE)"

# Default target
build:
Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ make build

2. **Run setup wizard:**
```bash
tibber config init
powerctl config init
```

3. **View your home:**
```bash
tibber home
powerctl home
```

## Usage
Expand All @@ -52,25 +52,35 @@ make build
**Option 1: Environment variable (recommended)**
```bash
export TIBBER_TOKEN="your-token-here"
tibber home
powerctl home
```

**Option 2: Config file**
```bash
tibber config init # Interactive setup
powerctl config init # Interactive setup
# or manually edit ~/.tibber/config.yaml
```

**Option 3: Command flag**
```bash
tibber --config /path/to/config.yaml home
powerctl --config /path/to/config.yaml home
```

### Commands

#### Check Version
```bash
powerctl version
```
```
powerctl-cli version 1.0.0
Git commit: a1b2c3d
Built: 2026-01-31T10:30:00Z
```

#### View Home Information
```bash
tibber home
powerctl home
```
```
⚡ My House
Expand All @@ -91,7 +101,7 @@ tibber home

#### Check Electricity Prices
```bash
tibber prices
powerctl prices
```
```
⚡ Electricity Prices
Expand All @@ -107,7 +117,7 @@ tibber prices

#### Stream Live Power Consumption
```bash
tibber live
powerctl live
```
```
⚡ Live Power
Expand All @@ -132,12 +142,12 @@ Default output is beautiful colored CLI. Change format with `--format`:

**JSON** (for scripting/piping):
```bash
tibber prices --format json | jq '.current.total'
powerctl prices --format json | jq '.current.total'
```

**Markdown** (for AI/documentation):
```bash
tibber home --format markdown
powerctl home --format markdown
```

## Configuration File
Expand All @@ -152,12 +162,12 @@ format: "pretty" # Options: pretty, json, markdown

View current config:
```bash
tibber config show
powerctl config show
```

Update a value:
```bash
tibber config set format json
powerctl config set format json
```

## Development
Expand Down Expand Up @@ -190,7 +200,7 @@ make lint # Run linter (requires golangci-lint)
## Troubleshooting

**"No API token found"**
- Set `TIBBER_TOKEN` environment variable or run `tibber config init`
- Set `TIBBER_TOKEN` environment variable or run `powerctl config init`

**"Pulse not enabled"**
- Ensure your Tibber Pulse is connected and active
Expand Down
32 changes: 32 additions & 0 deletions internal/commands/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package commands

import (
"fmt"

"github.com/spf13/cobra"
)

var (
// Version is the current version of powerctl-cli
// This can be overridden at build time using -ldflags
Version = "dev"
// GitCommit is the git commit hash (set at build time)
GitCommit = "unknown"
// BuildDate is when the binary was built (set at build time)
BuildDate = "unknown"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version information",
Long: `Display the current version, git commit, and build date of powerctl-cli.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("powerctl-cli version %s\n", Version)
fmt.Printf("Git commit: %s\n", GitCommit)
fmt.Printf("Built: %s\n", BuildDate)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}
Loading