forked from x/icebergs
add copy
This commit is contained in:
parent
8a203b52ae
commit
5783c5f09a
@ -8,6 +8,7 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -165,6 +166,18 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
"copy": {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if f, _, e := kit.Create(arg[0]); m.Assert(e) {
|
||||||
|
defer f.Close()
|
||||||
|
for _, v := range arg[1:] {
|
||||||
|
if s, e := os.Open(v); !m.Warn(e != nil, "%s", e) {
|
||||||
|
if n, e := io.Copy(f, s); m.Assert(e) {
|
||||||
|
m.Log(ice.LOG_IMPORT, "%d: %v", n, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ var title = `<{{.Option "level"}} class="story" data-type="{{.Option "type"}}" d
|
|||||||
var brief = `<p class="story" data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "input"}}">{{.Option "text"}}</p>`
|
var brief = `<p class="story" data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "input"}}">{{.Option "text"}}</p>`
|
||||||
var refer = `<ul class="story"
|
var refer = `<ul class="story"
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
||||||
{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`
|
{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}} {{index $value 1}}</li>{{end}}</ul>`
|
||||||
var spark = `<p>{{.}}</p>`
|
var spark = `<p>{{.}}</p>`
|
||||||
|
|
||||||
var shell = `<div class="story code" data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "input"}}">$ {{.Option "input"}}
|
var shell = `<div class="story code" data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "input"}}">$ {{.Option "input"}}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -101,9 +102,10 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
|
|
||||||
switch arg = arg[2:]; arg[0] {
|
switch arg = arg[2:]; arg[0] {
|
||||||
case "install", "compile":
|
case "install", "compile":
|
||||||
m.Option("input", strings.Join(arg[1:], " "))
|
m.Option("input", html.EscapeString(strings.Join(arg[1:], " ")))
|
||||||
default:
|
default:
|
||||||
m.Option("output", m.Cmdx("cli.system", "sh", "-c", m.Option("input", strings.Join(arg, " "))))
|
m.Option("input", html.EscapeString(strings.Join(arg, " ")))
|
||||||
|
m.Option("output", html.EscapeString(m.Cmdx("cli.system", "sh", "-c", strings.Join(arg, " "))))
|
||||||
}
|
}
|
||||||
m.Render(m.Conf("spark", ice.Meta("template")), m.Option("name"))
|
m.Render(m.Conf("spark", ice.Meta("template")), m.Option("name"))
|
||||||
m.Render(m.Conf("shell", ice.Meta("template")))
|
m.Render(m.Conf("shell", ice.Meta("template")))
|
||||||
@ -120,7 +122,11 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
m.Option("type", "refer")
|
m.Option("type", "refer")
|
||||||
m.Option("name", arg[0])
|
m.Option("name", arg[0])
|
||||||
m.Option("text", arg[1])
|
m.Option("text", arg[1])
|
||||||
m.Optionv("list", kit.Split(arg[1], "\n"))
|
list := []interface{}{}
|
||||||
|
for _, v := range kit.Split(arg[1], "\n") {
|
||||||
|
list = append(list, kit.Split(v, " "))
|
||||||
|
}
|
||||||
|
m.Optionv("list", list)
|
||||||
m.Render(m.Conf("order", ice.Meta("template")))
|
m.Render(m.Conf("order", ice.Meta("template")))
|
||||||
}},
|
}},
|
||||||
"brief": {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"brief": {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
@ -50,9 +50,9 @@ mkdir miss; cd miss && curl -s https://shylinux.com/publish/build.sh | sh
|
|||||||
mkdir miss; cd miss && curl -s https://shylinux.com/publish/ice.sh | sh
|
mkdir miss; cd miss && curl -s https://shylinux.com/publish/ice.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
## {{chapter "元始模块 base/ctx"}}
|
## {{chapter "配置模块 base/ctx"}}
|
||||||
|
|
||||||
## {{chapter "配置模块 base/cli"}}
|
## {{chapter "命令模块 base/cli"}}
|
||||||
cli模块用于与系统进行交互。
|
cli模块用于与系统进行交互。
|
||||||
|
|
||||||
- 系统信息 ice.CLI_RUNTIME
|
- 系统信息 ice.CLI_RUNTIME
|
||||||
|
Loading…
x
Reference in New Issue
Block a user