增加lua调试功能

This commit is contained in:
algotao
2025-09-02 15:45:56 +08:00
parent ed06c46bde
commit fff023b56d
10 changed files with 200 additions and 10 deletions

40
cmd/saastool/script.go Normal file
View File

@@ -0,0 +1,40 @@
package main
import (
"fmt"
"os"
"strings"
)
func RunScript(args ...string) error {
name, args := ParseCommandName(args)
// 从参数中解析出命令
switch name {
case "", "help":
return RunScriptHelp(args...)
case "run":
return RunScriptRun(args...)
default:
err := fmt.Errorf(`unknown command "%s"`+"\n"+`Run 'saastool script help' for usage`, name)
fmt.Fprintln(os.Stderr, err)
return err
}
}
func RunScriptHelp(args ...string) error {
fmt.Println(strings.TrimSpace(scriptUsage))
return nil
}
const scriptUsage = `
Usage: saastoola script COMMAND [OPTIONS]
Commands:
run Run lua script test on server
"help" is the default command.
Use "saastool script COMMAND -help" for more information about a command.
`