()
| 15 | } |
| 16 | |
| 17 | func mainAux() int { |
| 18 | var opt_e, opt_l, opt_p string |
| 19 | var opt_i, opt_v, opt_dt, opt_dc bool |
| 20 | var opt_m int |
| 21 | flag.StringVar(&opt_e, "e", "", "") |
| 22 | flag.StringVar(&opt_l, "l", "", "") |
| 23 | flag.StringVar(&opt_p, "p", "", "") |
| 24 | flag.IntVar(&opt_m, "mx", 0, "") |
| 25 | flag.BoolVar(&opt_i, "i", false, "") |
| 26 | flag.BoolVar(&opt_v, "v", false, "") |
| 27 | flag.BoolVar(&opt_dt, "dt", false, "") |
| 28 | flag.BoolVar(&opt_dc, "dc", false, "") |
| 29 | flag.Usage = func() { |
| 30 | fmt.Println(`Usage: glua [options] [script [args]]. |
| 31 | Available options are: |
| 32 | -e stat execute string 'stat' |
| 33 | -l name require library 'name' |
| 34 | -mx MB memory limit(default: unlimited) |
| 35 | -dt dump AST trees |
| 36 | -dc dump VM codes |
| 37 | -i enter interactive mode after executing 'script' |
| 38 | -p file write cpu profiles to the file |
| 39 | -v show version information`) |
| 40 | } |
| 41 | flag.Parse() |
| 42 | if len(opt_p) != 0 { |
| 43 | f, err := os.Create(opt_p) |
| 44 | if err != nil { |
| 45 | fmt.Println(err.Error()) |
| 46 | os.Exit(1) |
| 47 | } |
| 48 | pprof.StartCPUProfile(f) |
| 49 | defer pprof.StopCPUProfile() |
| 50 | } |
| 51 | if len(opt_e) == 0 && !opt_i && !opt_v && flag.NArg() == 0 { |
| 52 | opt_i = true |
| 53 | } |
| 54 | |
| 55 | status := 0 |
| 56 | |
| 57 | L := lua.NewState() |
| 58 | defer L.Close() |
| 59 | if opt_m > 0 { |
| 60 | L.SetMx(opt_m) |
| 61 | } |
| 62 | |
| 63 | if opt_v || opt_i { |
| 64 | fmt.Println(lua.PackageCopyRight) |
| 65 | } |
| 66 | |
| 67 | if len(opt_l) > 0 { |
| 68 | if err := L.DoFile(opt_l); err != nil { |
| 69 | fmt.Println(err.Error()) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | if nargs := flag.NArg(); nargs > 0 { |
| 74 | script := flag.Arg(0) |
no test coverage detected
searching dependent graphs…