diff options
author | Ayke van Laethem <[email protected]> | 2022-04-15 17:29:21 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-04-16 18:37:03 +0200 |
commit | d58c7d252130a601afbdaa6ac64317ec4c672958 (patch) | |
tree | 3d7c6503b74d8938b278ac6256d818e99718cd0b /main.go | |
parent | 85f5411d60313e00df2f12f0c9a70471d591dcda (diff) | |
download | tinygo-d58c7d252130a601afbdaa6ac64317ec4c672958.tar.gz tinygo-d58c7d252130a601afbdaa6ac64317ec4c672958.zip |
main: add support for command-line parameters to `tinygo run`
This is made easy by the refactor in the previous commit.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -709,13 +709,13 @@ func Debug(debugger, pkgName string, ocdOutput bool, options *compileopts.Option // the options, it will run the program directly on the host or will run it in // an emulator. For example, -target=wasm will cause the binary to be run inside // of a WebAssembly VM. -func Run(pkgName string, options *compileopts.Options) error { +func Run(pkgName string, options *compileopts.Options, cmdArgs []string) error { config, err := builder.NewConfig(options) if err != nil { return err } - return buildAndRun(pkgName, config, os.Stdout, nil, nil, 0) + return buildAndRun(pkgName, config, os.Stdout, cmdArgs, nil, 0) } // buildAndRun builds and runs the given program, writing output to stdout and @@ -1495,13 +1495,13 @@ func main() { handleCompilerError(err) } case "run": - if flag.NArg() != 1 { + if flag.NArg() < 1 { fmt.Fprintln(os.Stderr, "No package specified.") usage(command) os.Exit(1) } pkgName := filepath.ToSlash(flag.Arg(0)) - err := Run(pkgName, options) + err := Run(pkgName, options, flag.Args()[1:]) handleCompilerError(err) case "test": var pkgNames []string |