Skip to content

Commit 403fee7

Browse files
authored
Add tinygo version subcommand (#172)
* cmd: add tinygo version subcommand to display current software version. Also displayed when usage is displayed
1 parent 7657238 commit 403fee7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os/exec"
1212
"os/signal"
1313
"path/filepath"
14+
"runtime"
1415
"strconv"
1516
"strings"
1617
"syscall"
@@ -455,6 +456,8 @@ func Run(pkgName, target string, config *BuildConfig) error {
455456
}
456457

457458
func usage() {
459+
fmt.Fprintln(os.Stderr, "TinyGo is a Go compiler for small places.")
460+
fmt.Fprintln(os.Stderr, "version:", version)
458461
fmt.Fprintf(os.Stderr, "usage: %s command [-printir] [-target=<target>] -o <output> <input>\n", os.Args[0])
459462
fmt.Fprintln(os.Stderr, "\ncommands:")
460463
fmt.Fprintln(os.Stderr, " build: compile packages and dependencies")
@@ -601,6 +604,8 @@ func main() {
601604
}
602605
case "help":
603606
usage()
607+
case "version":
608+
fmt.Printf("tinygo version %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH)
604609
default:
605610
fmt.Fprintln(os.Stderr, "Unknown command:", command)
606611
usage()

version.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package main
2+
3+
// version of this package.
4+
// Update this value before release of new version of software.
5+
const version = "0.1.0"

0 commit comments

Comments
 (0)