Skip to content

Commit c43abd7

Browse files
committed
Print dh-make-golang version at the start of make
Set to v0.3.3 release
1 parent 21ce8b5 commit c43abd7

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

main.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@ import (
88
"github.com/gregjones/httpcache"
99
)
1010

11+
const program = "dh-make-golang"
12+
1113
var (
1214
gitHub *github.Client
1315
)
1416

1517
func usage() {
16-
fmt.Fprintf(os.Stderr, "%s is a tool that converts Go packages into Debian package source.\n", os.Args[0])
18+
fmt.Fprintf(os.Stderr, "%s\n", buildVersionString())
19+
fmt.Fprintf(os.Stderr, "\n")
20+
fmt.Fprintf(os.Stderr, "%s is a tool that converts Go packages into Debian package source.\n", program)
1721
fmt.Fprintf(os.Stderr, "\n")
18-
fmt.Fprintf(os.Stderr, "Usage:\n\t%s [globalflags] <command> [flags] <args>\n", os.Args[0])
22+
fmt.Fprintf(os.Stderr, "Usage:\n\t%s [globalflags] <command> [flags] <args>\n", program)
1923
fmt.Fprintf(os.Stderr, "\n")
20-
fmt.Fprintf(os.Stderr, "%s commands:\n", os.Args[0])
24+
fmt.Fprintf(os.Stderr, "%s commands:\n", program)
2125
fmt.Fprintf(os.Stderr, "\tmake\t\t\tcreate a Debian package\n")
2226
fmt.Fprintf(os.Stderr, "\tsearch\t\t\tsearch Debian for already-existing packages\n")
2327
fmt.Fprintf(os.Stderr, "\testimate\t\testimate the amount of work for a package\n")
2428
fmt.Fprintf(os.Stderr, "\tcreate-salsa-project\tcreate a project for hosting Debian packaging\n")
2529
fmt.Fprintf(os.Stderr, "\n")
2630
fmt.Fprintf(os.Stderr, "For backwards compatibility, when no command is specified,\nthe make command is executed.\n")
2731
fmt.Fprintf(os.Stderr, "\n")
28-
fmt.Fprintf(os.Stderr, "To learn more about a command, run \"%s <command> -help\",\ne.g. \"%s make -help\"\n", os.Args[0], os.Args[0])
32+
fmt.Fprintf(os.Stderr, "To learn more about a command, run \"%s <command> -help\",\ne.g. \"%s make -help\"\n", program, program)
2933
fmt.Fprintf(os.Stderr, "\n")
3034
}
3135

make.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,14 @@ func execMake(args []string, usage func()) {
784784
"Valid values are \"a\", \"at\" and \"ast\", see wrap-and-sort(1) man page\n"+
785785
"for more information.")
786786

787+
// ====================================================================
788+
//
789+
// Start actual make routine
790+
//
791+
// ====================================================================
792+
793+
log.Printf("Starting %q", buildVersionString())
794+
787795
err := fs.Parse(args)
788796
if err != nil {
789797
log.Fatal(err)

version_current.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"runtime"
6+
)
7+
8+
// Version represents the dh-make-golang build version.
9+
type Version struct {
10+
major int
11+
minor int
12+
patch int
13+
preRelease string
14+
}
15+
16+
var currentVersion = Version{
17+
major: 0,
18+
minor: 3,
19+
patch: 3,
20+
preRelease: "",
21+
}
22+
23+
func (v Version) String() string {
24+
return fmt.Sprintf("%d.%d.%d%s", v.major, v.minor, v.patch, v.preRelease)
25+
}
26+
27+
func buildVersionString() string {
28+
version := "v" + currentVersion.String()
29+
osArch := runtime.GOOS + "/" + runtime.GOARCH
30+
return fmt.Sprintf("%s %s %s", program, version, osArch)
31+
}

0 commit comments

Comments
 (0)