llgo build/install/run: SkipArgs bugfix

This commit is contained in:
xushiwei
2024-04-27 06:39:09 +08:00
parent ea8ddc6451
commit 3cc83b8ec4
4 changed files with 82 additions and 30 deletions

View File

@@ -33,8 +33,13 @@ func init() {
}
func runCmd(cmd *base.Command, args []string) {
build.Do(args, &build.Config{
conf := &build.Config{
Mode: build.ModeBuild,
AppExt: build.DefaultAppExt(),
})
}
if len(args) >= 2 && args[0] == "-o" {
conf.OutFile = args[1]
args = args[2:]
}
build.Do(args, conf)
}

View File

@@ -20,7 +20,6 @@ package run
import (
"errors"
"path/filepath"
"strings"
"github.com/goplus/llgo/cmd/internal/base"
"github.com/goplus/llgo/internal/build"
@@ -49,7 +48,7 @@ func runCmd(cmd *base.Command, args []string) {
}
func parseRunArgs(args []string) ([]string, []string, error) {
n := parseArgs(args)
n := build.SkipArgs(args)
if n < 0 {
return nil, nil, errNoProj
}
@@ -65,15 +64,6 @@ func parseRunArgs(args []string) ([]string, []string, error) {
return args[:n+1], args[n+1:], nil
}
func parseArgs(args []string) int {
for i, arg := range args {
if !strings.HasPrefix(arg, "-") {
return i
}
}
return -1
}
func isGoFile(fname string) bool {
return filepath.Ext(fname) == ".go"
}