gagent/src/picol
2021-06-02 05:59:48 -07:00
..
examples fix: (issues/9) Worker does not support port assignment for routers (#11) 2021-05-21 23:03:50 +00:00
picol fix: [CI SKIP] Continuing cleanup based on the report card. 2021-06-02 05:44:21 -07:00
commands.go fix: [CI SKIP] Adding export comments, most are prolly wrong. 2021-06-02 05:59:48 -07:00
LICENSE fix: (issues/9) Worker does not support port assignment for routers (#11) 2021-05-21 23:03:50 +00:00
parser.go fix: [CI SKIP] Missed a file. 2021-06-02 05:44:58 -07:00
picol.go style: Adjusting Picol format / syntax to match modern standards. 2021-05-21 18:46:26 -07:00
README.md fix: (issues/9) Worker does not support port assignment for routers (#11) 2021-05-21 23:03:50 +00:00

picol.go

Original http://oldblog.antirez.com/post/picol.html

Sample use:

func CommandPuts(i *picol.Interp, argv []string, pd interface{}) (string, error) {
	if len(argv) != 2 {
		return "", fmt.Errorf("Wrong number of args for %s %s", argv[0], argv)
	}
	fmt.Println(argv[1])
	return "", nil
}
...
	interp := picol.InitInterp()
	// add core functions
	interp.RegisterCoreCommands()
	// add user function
	interp.RegisterCommand("puts", CommandPuts, nil)
	// eval
	result, err := interp.Eval(string(buf))
	if err != nil {
		fmt.Println("ERROR", err, result)
	} else {
		fmt.Println(result)
	}