MCPcopy Create free account
hub / github.com/cloudwan/gohan / getRunCommand

Function getRunCommand

cli/cli.go:518–555  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

516}
517
518func getRunCommand() cli.Command {
519 return cli.Command{
520 Name: "run",
521 ShortName: "run",
522 Usage: "Run Gohan script Code",
523 Description: `
524Run gohan script code.`,
525 Flags: []cli.Flag{
526 cli.StringFlag{Name: "config-file,c", Value: defaultConfigFile, Usage: "config file path"},
527 cli.StringFlag{Name: "args,a", Value: "", Usage: "arguments"},
528 },
529 Action: func(c *cli.Context) {
530 src := c.Args()[0]
531 vm := gohanscript.NewVM()
532
533 args := []interface{}{}
534 flags := map[string]interface{}{}
535 for _, arg := range c.Args()[1:] {
536 if strings.Contains(arg, "=") {
537 kv := strings.Split(arg, "=")
538 flags[kv[0]] = kv[1]
539 } else {
540 args = append(args, arg)
541 }
542 }
543 vm.Context.Set("args", args)
544 vm.Context.Set("flags", flags)
545 configFile := c.String("config-file")
546 loadConfig(configFile)
547 _, err := vm.RunFile(src)
548 if err != nil {
549 fmt.Println(err)
550 os.Exit(1)
551 return
552 }
553 },
554 }
555}
556
557func getTestCommand() cli.Command {
558 return cli.Command{

Callers 1

RunFunction · 0.85

Calls 6

RunFileMethod · 0.95
loadConfigFunction · 0.85
ArgsMethod · 0.80
ContainsMethod · 0.80
SetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected