mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add grep search
This commit is contained in:
parent
e077dcfca5
commit
8065a7dc98
@ -7,5 +7,5 @@ var version = struct {
|
||||
self int
|
||||
}{
|
||||
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
||||
`2019-10-23 08:31:12`, `mac`, 647,
|
||||
`2019-10-24 08:04:57`, `mac`, 652,
|
||||
}
|
||||
|
@ -911,6 +911,9 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
"grep": &ctx.Command{Name: "grep head|tail|hold|more table arg", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
hold := false
|
||||
switch arg[0] {
|
||||
case "search":
|
||||
m.Cmdy("cli.system", "grep", arg[1:])
|
||||
|
||||
case "add":
|
||||
m.Confv("grep", []string{arg[1], "list", "-2"}, map[string]interface{}{
|
||||
"pos": 0, "offset": 0, "file": arg[2],
|
||||
|
3
src/plugin/redis/index.css
Normal file
3
src/plugin/redis/index.css
Normal file
@ -0,0 +1,3 @@
|
||||
fieldset.item.redis div.output {
|
||||
}
|
||||
|
36
src/plugin/redis/index.go
Normal file
36
src/plugin/redis/index.go
Normal file
@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"contexts/cli"
|
||||
"contexts/ctx"
|
||||
"toolkit"
|
||||
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var Index = &ctx.Context{Name: `redis`, Help: `plugin`,
|
||||
Caches: map[string]*ctx.Cache{},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"_index": &ctx.Config{Name: "index", Value: []interface{}{
|
||||
map[string]interface{}{"name": "demo", "help": "demo",
|
||||
"tmpl": "componet", "view": "", "init": "",
|
||||
"type": "public", "ctx": "demo", "cmd": "demo",
|
||||
"args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"demo": {Name: "demo", Help: "demo", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Echo(kit.Select("hello world", arg, 0))
|
||||
return
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Print(cli.Index.Plugin(Index, os.Args[1:]))
|
||||
}
|
3
src/plugin/redis/index.js
Normal file
3
src/plugin/redis/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
Script["redis/index.js"] = function(field, option, output) {return {
|
||||
}}
|
||||
|
54
src/plugin/redis/index.shy
Normal file
54
src/plugin/redis/index.shy
Normal file
@ -0,0 +1,54 @@
|
||||
fun download "下载" public \
|
||||
text "redis-5.0.5.tar.gz" name src view long \
|
||||
button "下载"
|
||||
|
||||
let local = "usr/local/"
|
||||
let path = $local + $1 - ".tar.gz"
|
||||
if $(path $path)
|
||||
return $path
|
||||
end
|
||||
|
||||
let src = "http://download.redis.io/releases/" + $1
|
||||
let usr = $local + $1
|
||||
web.get method GET "" $src save $usr
|
||||
|
||||
tar xvf $usr -C $local
|
||||
make -C $path
|
||||
return $path
|
||||
end
|
||||
|
||||
kit dir "目录" public "nfs.dir" _ time size line path \
|
||||
text "usr/local/redis-5.0.5" name dir imports plugin_dir action auto view long \
|
||||
button "浏览" action auto \
|
||||
button "返回" cb Last \
|
||||
feature display editor \
|
||||
exports dir "" dir
|
||||
|
||||
kit grep "搜索" public "nfs.grep" search _ _ "-rn" "--color" cmd_parse cut 3 ":" "file line word" \
|
||||
text "" name txt imports plugin_editor_word \
|
||||
text "usr/local/redis-5.0.5" name dir view long \
|
||||
button "搜索" \
|
||||
exports dir file "" editor_file file "" editor_index line ""
|
||||
|
||||
fun mark "标签" public \
|
||||
text "mark" name table \
|
||||
text "" name file imports plugin_editor_file view long \
|
||||
text "" name index imports plugin_editor_index view tiny \
|
||||
text "" name word imports plugin_editor_word \
|
||||
text "" name mark view long \
|
||||
button "操作" \
|
||||
exports dir file "" editor_index index "" editor_word word
|
||||
|
||||
if $5 == ""
|
||||
copy skip ssh.data show _
|
||||
else
|
||||
copy ssh.data insert _ file _ index _ word _ mark _
|
||||
end
|
||||
end
|
||||
|
||||
fun hello world "" "" public \
|
||||
text "" \
|
||||
button "执行"
|
||||
copy pwd
|
||||
|
||||
end
|
@ -1204,7 +1204,11 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
}, JSON.parse(meta.exports||'["",""]'), function(event, value, name, line) {
|
||||
var meta = arguments.callee.meta
|
||||
var list = arguments.callee.list
|
||||
;(!list[1] || list[1] == name) && page.Sync("plugin_"+list[0]).set(meta[list[2]||""](value, name, line, list))
|
||||
if (list[1] && list[1] != name) {return}
|
||||
|
||||
for (var i = 0; i < list.length; i += 3) {
|
||||
page.Sync("plugin_"+list[i]).set(meta[list[i+2]||""](list[i+1]? line[list[i+1]]: value, list[i+1]||name, line, list))
|
||||
}
|
||||
}),
|
||||
onchoice: shy("菜单列表", {
|
||||
"返回": "Last",
|
||||
@ -1428,15 +1432,21 @@ function Output(plugin, type, msg, cb, target, option) {
|
||||
editor: function(msg, cb) {
|
||||
target.innerHTML = ""
|
||||
output.onimport.meta._table(msg, msg.append)
|
||||
var current = page.Sync("plugin_editor_index").get()
|
||||
target.style.maxHeight = ""
|
||||
if (msg.file) {
|
||||
target.style.maxHeight = "500px"
|
||||
var code = kit.AppendChild(target, [{view: ["code", "table"], list: kit.List(msg.result, function(line, index) {
|
||||
return {view: ["line", "tr"], list: [{view: ["number", "td", index+1]}, {view: ["code", "td", kit.Color(line)], style: {"white-space": "pre"}}], click: function(event) {
|
||||
return {view: ["line"+ (current == index+1? " select": ""), "tr"], list: [{view: ["number", "td", index+1]}, {view: ["code", "td", kit.Color(line)], style: {"white-space": "pre"}}], click: function(event) {
|
||||
page.Sync("plugin_editor_file").set(msg.file[0])
|
||||
page.Sync("plugin_editor_index").set(index+1)
|
||||
page.Sync("plugin_editor_line").set(line)
|
||||
page.Sync("plugin_editor_word").set(kit.CopyText())
|
||||
}}
|
||||
})}])
|
||||
kit.Selector(target, "tr.line.select", function(tr) {
|
||||
tr.scrollIntoView()
|
||||
})
|
||||
}
|
||||
typeof cb == "function" && cb(msg)
|
||||
return
|
||||
@ -1455,9 +1465,10 @@ function Output(plugin, type, msg, cb, target, option) {
|
||||
"表格": "_table",
|
||||
"绘图": "_canvas",
|
||||
"下载": "Download",
|
||||
"返回": "Last",
|
||||
"清空": "clear",
|
||||
}, ["表格", "绘图", "下载", "清空"], function(event, value, meta) {
|
||||
kit._call(output, output[meta[value]])
|
||||
}, ["表格", "绘图", "下载", "返回", "清空"], function(event, value, meta) {
|
||||
kit._call(output, output[meta[value]], [event])
|
||||
return true
|
||||
}),
|
||||
onaction: shy("事件列表", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user