| 1 | package main |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | const usage = `Yaegi is a Go interpreter. |
| 6 | |
| 7 | Usage: |
| 8 | |
| 9 | yaegi [command] [arguments] |
| 10 | |
| 11 | The commands are: |
| 12 | |
| 13 | extract generate a wrapper file from a source package |
| 14 | help print usage information |
| 15 | run execute a Go program from source |
| 16 | test execute test functions in a Go package |
| 17 | version print version |
| 18 | |
| 19 | Use "yaegi help <command>" for more information about a command. |
| 20 | |
| 21 | If no command is given or if the first argument is not a command, then |
| 22 | the run command is assumed. |
| 23 | ` |
| 24 | |
| 25 | func help(arg []string) error { |
| 26 | var cmd string |
| 27 | if len(arg) > 0 { |
| 28 | cmd = arg[0] |
| 29 | } |
| 30 | |
| 31 | switch cmd { |
| 32 | case Extract: |
| 33 | return extractCmd([]string{"-h"}) |
| 34 | case Help, "", "-h", "--help": |
| 35 | fmt.Print(usage) |
| 36 | return nil |
| 37 | case Run: |
| 38 | return run([]string{"-h"}) |
| 39 | case Test: |
| 40 | return test([]string{"-h"}) |
| 41 | case Version: |
| 42 | fmt.Println("Usage: yaegi version") |
| 43 | return nil |
| 44 | default: |
| 45 | return fmt.Errorf("help: invalid yaegi command: %v", cmd) |
| 46 | } |
| 47 | } |