From fc69e5cd01f1fe6b0e7e2a54d3bedd59cf3fbee2 Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Wed, 6 Feb 2019 17:35:08 +0100 Subject: [PATCH 1/3] cmd: add tinygo version subcommand to display current software version. Also displayed when usage is displayed Signed-off-by: Ron Evans --- main.go | 5 +++++ version.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 version.go diff --git a/main.go b/main.go index 65f2effbd5..ef8a14de13 100644 --- a/main.go +++ b/main.go @@ -455,6 +455,8 @@ func Run(pkgName, target string, config *BuildConfig) error { } func usage() { + fmt.Fprintln(os.Stderr, "TinyGo is a Go compiler for small places.") + fmt.Fprintln(os.Stderr, displayversion()) fmt.Fprintf(os.Stderr, "usage: %s command [-printir] [-target=] -o \n", os.Args[0]) fmt.Fprintln(os.Stderr, "\ncommands:") fmt.Fprintln(os.Stderr, " build: compile packages and dependencies") @@ -601,6 +603,9 @@ func main() { } case "help": usage() + case "version": + fmt.Fprintln(os.Stderr, displayversion()) + version() default: fmt.Fprintln(os.Stderr, "Unknown command:", command) usage() diff --git a/version.go b/version.go new file mode 100644 index 0000000000..099ed97366 --- /dev/null +++ b/version.go @@ -0,0 +1,15 @@ +package main + +// tinyGoVersion of this package. +// Update this value before release of new version of software. +const tinyGoVersion = "0.1.0" + +// version returns the current TinyGo version +func version() string { + return tinyGoVersion +} + +// displayversion returns the current TinyGo full version description for display purposes. +func displayversion() string { + return "TinyGo compiler v" + tinyGoVersion +} From ba23d512c04a38455091cc0e8442144b2a3db467 Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Thu, 7 Feb 2019 19:07:07 +0100 Subject: [PATCH 2/3] cmd: improvements and simplifications to version subcommand Signed-off-by: Ron Evans --- main.go | 6 +++--- version.go | 14 ++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index ef8a14de13..cca6c5f1b7 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "os/exec" "os/signal" "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -456,7 +457,7 @@ func Run(pkgName, target string, config *BuildConfig) error { func usage() { fmt.Fprintln(os.Stderr, "TinyGo is a Go compiler for small places.") - fmt.Fprintln(os.Stderr, displayversion()) + fmt.Fprintln(os.Stderr, "version:", version) fmt.Fprintf(os.Stderr, "usage: %s command [-printir] [-target=] -o \n", os.Args[0]) fmt.Fprintln(os.Stderr, "\ncommands:") fmt.Fprintln(os.Stderr, " build: compile packages and dependencies") @@ -604,8 +605,7 @@ func main() { case "help": usage() case "version": - fmt.Fprintln(os.Stderr, displayversion()) - version() + fmt.Printf("TinyGo version %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH) default: fmt.Fprintln(os.Stderr, "Unknown command:", command) usage() diff --git a/version.go b/version.go index 099ed97366..7ad5c73c47 100644 --- a/version.go +++ b/version.go @@ -1,15 +1,5 @@ package main -// tinyGoVersion of this package. +// version of this package. // Update this value before release of new version of software. -const tinyGoVersion = "0.1.0" - -// version returns the current TinyGo version -func version() string { - return tinyGoVersion -} - -// displayversion returns the current TinyGo full version description for display purposes. -func displayversion() string { - return "TinyGo compiler v" + tinyGoVersion -} +const version = "0.1.0" From 9edd56119e6fb3787395d3164f764c5477ba492b Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Fri, 8 Feb 2019 10:00:46 +0100 Subject: [PATCH 3/3] cmd: make the output of usage all lowercase like the 'go version' command does Signed-off-by: Ron Evans --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index cca6c5f1b7..64e8b91334 100644 --- a/main.go +++ b/main.go @@ -605,7 +605,7 @@ func main() { case "help": usage() case "version": - fmt.Printf("TinyGo version %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH) + fmt.Printf("tinygo version %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH) default: fmt.Fprintln(os.Stderr, "Unknown command:", command) usage()