From 8f1a284feb59f627708f8a5f009477605d7442f0 Mon Sep 17 00:00:00 2001 From: shylinux Date: Thu, 6 Apr 2023 15:35:23 +0800 Subject: [PATCH] add yac.type --- Makefile | 1 + src/back.shy | 96 ++++++++++++++++++++++++++ src/demo.shy | 66 ++++++------------ src/script/web.chat.favor/list.shy | 8 +++ src/script/web.chat.favor/onimport.shy | 4 ++ src/shy/data.shy | 6 ++ 6 files changed, 135 insertions(+), 46 deletions(-) create mode 100644 src/script/web.chat.favor/list.shy create mode 100644 src/script/web.chat.favor/onimport.shy create mode 100644 src/shy/data.shy diff --git a/Makefile b/Makefile index 01b306bc..3fae4eed 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ binpack = src/binpack.go all: def @date +"%Y-%m-%d %H:%M:%S" go build -v -o ${binarys} src/main.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null + # go build -v -o ${binarys} src/main.go ${version} ${binpack} app: def CGO_ENABLED=1 go build -v -o ${publish}/contexts.app/Contents/MacOS/contexts src/webview.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null diff --git a/src/back.shy b/src/back.shy index 1c197f1f..fc970e40 100644 --- a/src/back.shy +++ b/src/back.shy @@ -1,6 +1,102 @@ #! yac.stack +package main + +var s1 = "" +var s2 = "" +var s3 = "" +var s4 = "" + +type student struct { + name string + age int +} + +func (s student) Name(m) { + m.Echo("hello %s world\n", s.name) + return s.name +} + +func demo() { + s1 = map[string]string{"hi": "hi"} + m.Echo("what %#v\n", s1) + + s2 = []string{"hi", "hi"} + m.Echo("what %#v\n", s2) + for k, v := range s1 { + } + + s3 = student{name: "shy"} + m.Echo("what %#v\n", s3) + m.Echo("what %#v\n", s3.Name()) + + s4 = struct{ name string }{name: "shy"} + m.Echo("what %#v\n", s4) + defer func() { m.Echo("hello defer\n") }() +} + +func init() { + s1 = map[string]string{"hi": "h1"} + m.Echo("what %#v\n", s1) + for k, v := range s1 { + m.Echo("what %v %v", k, v) + } + s2 = []string{"h0", "h1"} + for i, v := range s2 { + m.Echo("what %v %v", i, v) + } +} + + +import ( + . "shylinux.com/x/contexts/src/shy" + _ "shylinux.com/x/contexts/src/shy" + kit "shylinux.com/x/toolkits" +) + +const ( + CONST1 = "const" +) +const VAR1 = "var" + +type student struct { + name string + age int +} + +func (s student) Name(a, b string) (c, d string) { + m.Echo("hello %s world", s.name) +} + +func Name(a, b string) (c, d string) { + m.Echo("hello world") +} + +var ( + const1 = "const" +) +var var1 = "var" + +func list(m, arg) { + show() + m.Echo("hello world") + Name() + show() + m.Echo("hello world") +} +func init() { + s := map[string]string{"hi": "hi"} + m.Echo("what %v", kit.Formats(s)) + + s := student{name: "hi"} + s.Name() + m.Echo("what %v", kit.Formats(s)) + s := map[string]student{"one": student{name: "hi"}} + m.Echo("what %v", kit.Formats(s)) + s := []student{"one": student{name: "hi"}} +} func list(m, arg, name) { + cli.system "pwd" m.Copy(cli.system("pwd")) m.Cmdy("cli.system", "pwd") m.Cmdy(cli.SYSTEM, "pwd") diff --git a/src/demo.shy b/src/demo.shy index 4e483738..0c539f2f 100644 --- a/src/demo.shy +++ b/src/demo.shy @@ -1,49 +1,23 @@ -#! yac.stack +package tmux -func list(m, arg, name) { - cli.system "pwd" - m.Copy(cli.system("pwd")) - m.Cmdy("cli.system", "pwd") - m.Cmdy(cli.SYSTEM, "pwd") - m.Cmdy(SYSTEM, "pwd") +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/cli" + kit "shylinux.com/x/toolkits" +) - m.Echo("%v", tcp.IsLocalHost(m, "127.0.0.1")) +func init() { m.DebugStack() } - defer func() { m.Echo("hello defer") }() - m.Push("h1", "hi").Push("h1", "he") - m.Table(func(value) { m.Echo(value["h1"]) }) - m.Cmdy("tcp.host") - m.Action("list1", "list2", "list3") -} -func inputs(m, key) { - switch key { - case "name": - m.Push(key, "hi") - default: - m.Push(key, "good") - } -} -func list1(m) { - let dict = kit.Dict("a", 1, "b", 2) - m.Echo("%#v", dict).Echo("\n") - m.Echo("%#v", dict["a"]).Echo("\n") - let data = kit.List("a", 1, "b", 2) - m.Echo("%#v", data).Echo("\n") - m.Echo("%#v", data[0]).Echo("\n") -} -func list2(m, name) { - if name == "h1" { - m.Echo("h1") - } else if name == "h2" { - m.Echo("h2") - } else { - m.Echo("h3") - } -} -func list3(m) { - for i = 0; i < 10; i++ { - m.Echo(i) - if i < 5 { continue } - if i > 1 { break } - } -} +const TMUX = "tmux" + +var Index = &ice.Context{Name: TMUX, Help: "工作台", Commands: ice.Commands{ + TMUX: {Name: "tmux path auto start order build download", Help: "服务", Actions: ice.MergeActions(ice.Actions{ + cli.START: {Help: "启动", Hand: func(m *ice.Message, arg ...string) {}}, + }), Hand: func(m *ice.Message, arg ...string) {}}, +}} + +// func init() { code.Index.Register(Index, &web.Frame{}) } +func init() { m.DebugStack() } +func init() { m.Echo(kit.Formats(Index)) } +func init() { m.Echo(kit.Formats(Index.Name)) } +func init() { m.Echo(kit.Formats(Index.Commands[TMUX].Name)) } diff --git a/src/script/web.chat.favor/list.shy b/src/script/web.chat.favor/list.shy new file mode 100644 index 00000000..c9899524 --- /dev/null +++ b/src/script/web.chat.favor/list.shy @@ -0,0 +1,8 @@ +func create(m, type) { + m.Echo("hello world") +} +func list(m, hash) { + m.Echo("hello world") + m.Echo("hello world") + m.Action("create").StatusTime().Display() +} \ No newline at end of file diff --git a/src/script/web.chat.favor/onimport.shy b/src/script/web.chat.favor/onimport.shy new file mode 100644 index 00000000..2ec291a2 --- /dev/null +++ b/src/script/web.chat.favor/onimport.shy @@ -0,0 +1,4 @@ +func _init(can, msg) { + msg.Echo("hello world") + msg.Dump(can) +} diff --git a/src/shy/data.shy b/src/shy/data.shy new file mode 100644 index 00000000..2d1767c5 --- /dev/null +++ b/src/shy/data.shy @@ -0,0 +1,6 @@ +#! yac.stack + +func show(m) { + m.Echo("hello world") +} +