forked from x/icebergs
add tutor
This commit is contained in:
parent
8181e3adea
commit
456afbba49
31
build.sh
31
build.sh
@ -74,5 +74,36 @@ build() {
|
||||
cd $miss && prepare && go build -o ice.bin main.go && chmod u+x ice.bin && ./ice.sh start serve dev
|
||||
}
|
||||
|
||||
tutor() {
|
||||
mkdir $1
|
||||
[ -f "$1/$1.go" ] || cat >> "$1/$1.go" <<END
|
||||
package $1
|
||||
|
||||
import (
|
||||
"github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
var Index = &ice.Context{Name: "$1", Help: "$1",
|
||||
Caches: map[string]*ice.Cache{},
|
||||
Configs: map[string]*ice.Config{
|
||||
"$1": {Name: "$1", Help: "$1", Value: kit.Data(kit.MDB_SHORT, "name")},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||
|
||||
"$1": {Name: "$1", Help: "$1", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Echo("hello world")
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
func init() { cli.Index.Register(Index, nil) }
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
cmd=build && [ "$1" != "" ] && cmd=$1 && shift
|
||||
$cmd $*
|
||||
|
@ -95,7 +95,12 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
|
||||
m.Option("type", "shell")
|
||||
m.Option("name", arg[0])
|
||||
m.Option("cmd_dir", arg[1])
|
||||
m.Option("output", m.Cmdx("cli.system", "sh", "-c", m.Option("input", strings.Join(arg[2:], " "))))
|
||||
switch arg[1] {
|
||||
case "-demo":
|
||||
m.Option("input", strings.Join(arg[2:], " "))
|
||||
default:
|
||||
m.Option("output", m.Cmdx("cli.system", "sh", "-c", m.Option("input", strings.Join(arg[2:], " "))))
|
||||
}
|
||||
m.Render(m.Conf("shell", ice.Meta("template")))
|
||||
}},
|
||||
"title": {Name: "title text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user