Skip to content

Commit

Permalink
Add a puku version command (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
toastwaffle authored Jul 26, 2024
1 parent 70b00cb commit c414d15
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ genrule(
cmd = "echo VERSION = \\\"$(cat $SRCS)\\\" > $OUT",
visibility = [
"//package:all",
"//cmd/puku:all",
],
)

Expand Down
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.10.0
-------------
* Adds a `puku version` command to report the version of puku that is installed.

Version 1.9.0
-------------
* `"stop": false` in a `puku.json` in a subdirectory will override a `"stop": true` in a parent
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.0
1.10.0
6 changes: 6 additions & 0 deletions cmd/puku/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
subinclude("//:version")

go_binary(
name = "puku",
srcs = ["puku.go"],
definitions = {
"github.com/please-build/puku/version.PukuVersion": VERSION,
},
visibility = ["PUBLIC"],
deps = [
"///third_party/go/github.com_peterebden_go-cli-init_v5//flags",
Expand All @@ -16,5 +21,6 @@ go_binary(
"//work",
"//graph",
"//sync",
"//version",
],
)
10 changes: 9 additions & 1 deletion cmd/puku/puku.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"os"
"path/filepath"

Expand All @@ -16,6 +17,7 @@ import (
"github.com/please-build/puku/please"
"github.com/please-build/puku/proxy"
"github.com/please-build/puku/sync"
"github.com/please-build/puku/version"
"github.com/please-build/puku/watch"
"github.com/please-build/puku/work"
)
Expand All @@ -24,7 +26,8 @@ var opts = struct {
Usage string
Verbosity clilogging.Verbosity `short:"v" long:"verbosity" description:"Verbosity of output (error, warning, notice, info, debug)" default:"info"`

Fmt struct {
Version struct{} `command:"version" description:"Print the version of puku"`
Fmt struct {
Args struct {
Paths []string `positional-arg-name:"packages" description:"The packages to process"`
} `positional-args:"true"`
Expand Down Expand Up @@ -147,6 +150,11 @@ func main() {
cmd := flags.ParseFlagsOrDie("puku", &opts, nil)
logging.InitLogging(opts.Verbosity)

if cmd == "version" {
fmt.Println("puku version", version.PukuVersion)
return
}

wd, err := os.Getwd()
if err != nil {
log.Fatalf("failed to get wd: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions version/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go_library(
name = "version",
srcs = ["version.go"],
visibility = ["//cmd/puku:all"],
)
6 changes: 6 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Package version contains the version of Puku.
package version

// PukuVersion is the current version of Puku.
// Building //cmd/puku replaces this fake version with a real one.
var PukuVersion = "99.0.9999"

0 comments on commit c414d15

Please sign in to comment.