Skip to content

Commit

Permalink
Print dh-make-golang version at the start of make
Browse files Browse the repository at this point in the history
Set to v0.3.3 release
  • Loading branch information
anthonyfok committed Feb 27, 2020
1 parent 21ce8b5 commit c43abd7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@ import (
"github.com/gregjones/httpcache"
)

const program = "dh-make-golang"

var (
gitHub *github.Client
)

func usage() {
fmt.Fprintf(os.Stderr, "%s is a tool that converts Go packages into Debian package source.\n", os.Args[0])
fmt.Fprintf(os.Stderr, "%s\n", buildVersionString())
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "%s is a tool that converts Go packages into Debian package source.\n", program)
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "Usage:\n\t%s [globalflags] <command> [flags] <args>\n", os.Args[0])
fmt.Fprintf(os.Stderr, "Usage:\n\t%s [globalflags] <command> [flags] <args>\n", program)
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "%s commands:\n", os.Args[0])
fmt.Fprintf(os.Stderr, "%s commands:\n", program)
fmt.Fprintf(os.Stderr, "\tmake\t\t\tcreate a Debian package\n")
fmt.Fprintf(os.Stderr, "\tsearch\t\t\tsearch Debian for already-existing packages\n")
fmt.Fprintf(os.Stderr, "\testimate\t\testimate the amount of work for a package\n")
fmt.Fprintf(os.Stderr, "\tcreate-salsa-project\tcreate a project for hosting Debian packaging\n")
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "For backwards compatibility, when no command is specified,\nthe make command is executed.\n")
fmt.Fprintf(os.Stderr, "\n")
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])
fmt.Fprintf(os.Stderr, "To learn more about a command, run \"%s <command> -help\",\ne.g. \"%s make -help\"\n", program, program)
fmt.Fprintf(os.Stderr, "\n")
}

Expand Down
8 changes: 8 additions & 0 deletions make.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,14 @@ func execMake(args []string, usage func()) {
"Valid values are \"a\", \"at\" and \"ast\", see wrap-and-sort(1) man page\n"+
"for more information.")

// ====================================================================
//
// Start actual make routine
//
// ====================================================================

log.Printf("Starting %q", buildVersionString())

err := fs.Parse(args)
if err != nil {
log.Fatal(err)
Expand Down
31 changes: 31 additions & 0 deletions version_current.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"fmt"
"runtime"
)

// Version represents the dh-make-golang build version.
type Version struct {
major int
minor int
patch int
preRelease string
}

var currentVersion = Version{
major: 0,
minor: 3,
patch: 3,
preRelease: "",
}

func (v Version) String() string {
return fmt.Sprintf("%d.%d.%d%s", v.major, v.minor, v.patch, v.preRelease)
}

func buildVersionString() string {
version := "v" + currentVersion.String()
osArch := runtime.GOOS + "/" + runtime.GOARCH
return fmt.Sprintf("%s %s %s", program, version, osArch)
}

0 comments on commit c43abd7

Please sign in to comment.