增加lua调试功能
This commit is contained in:
40
cmd/saastool/script.go
Normal file
40
cmd/saastool/script.go
Normal 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.
|
||||
`
|
||||
Reference in New Issue
Block a user