aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCarolyn Van Slyck <[email protected]>2019-06-18 08:22:26 -0500
committerRon Evans <[email protected]>2019-06-20 19:05:06 +0200
commitce9b21a270fdf84d5760e244d8ebb64cd25ccf90 (patch)
treece4aaf8cbd0ba460863251356a102b2860c57cdf
parented7c242a09f490c0f71c159e6a96253d8cd0f429 (diff)
downloadtinygo-ce9b21a270fdf84d5760e244d8ebb64cd25ccf90.tar.gz
tinygo-ce9b21a270fdf84d5760e244d8ebb64cd25ccf90.zip
Default package name to . when not specified
When running tinygo build, and the positional argument for the package is not specified, default it to "."
-rw-r--r--main.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/main.go b/main.go
index 454ed73e2..546125379 100644
--- a/main.go
+++ b/main.go
@@ -640,8 +640,11 @@ func main() {
usage()
os.Exit(1)
}
- if flag.NArg() != 1 {
- fmt.Fprintln(os.Stderr, "No package specified.")
+ pkgName := "."
+ if flag.NArg() == 1 {
+ pkgName = flag.Arg(0)
+ } else if flag.NArg() > 1 {
+ fmt.Fprintln(os.Stderr, "build only accepts a single positional argument: package name, but multiple were specified")
usage()
os.Exit(1)
}
@@ -649,7 +652,7 @@ func main() {
if target == "" && filepath.Ext(*outpath) == ".wasm" {
target = "wasm"
}
- err := Build(flag.Arg(0), *outpath, target, config)
+ err := Build(pkgName, *outpath, target, config)
handleCompilerError(err)
case "build-builtins":
// Note: this command is only meant to be used while making a release!
@@ -692,11 +695,15 @@ func main() {
err := Run(flag.Arg(0), *target, config)
handleCompilerError(err)
case "test":
- pkgRoot := "."
+ pkgName := "."
if flag.NArg() == 1 {
- pkgRoot = flag.Arg(0)
+ pkgName = flag.Arg(0)
+ } else if flag.NArg() > 1 {
+ fmt.Fprintln(os.Stderr, "test only accepts a single positional argument: package name, but multiple were specified")
+ usage()
+ os.Exit(1)
}
- err := Test(pkgRoot, *target, config)
+ err := Test(pkgName, *target, config)
handleCompilerError(err)
case "clean":
// remove cache directory