Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 08af230

Browse files
committed
准备v0.1.8.2(v0.1.9的预览版)
1 parent 97bbec4 commit 08af230

7 files changed

Lines changed: 121 additions & 179 deletions

File tree

teaconfigs/agents/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,9 @@ func (this *AgentConfig) FirstGroup() *Group {
635635

636636
// 判断是否匹配关键词
637637
func (this *AgentConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string) {
638-
if teautils.MatchKeyword(this.Name, keyword) || teautils.MatchKeyword(this.Host, keyword) {
638+
if teautils.MatchKeyword(this.Name, keyword) ||
639+
teautils.MatchKeyword(this.Host, keyword) ||
640+
this.Id == keyword {
639641
matched = true
640642
name = this.Name
641643
if len(this.Host) > 0 {

teaconst/const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package teaconst
22

33
const (
4-
TeaVersion = "0.1.8.1"
4+
TeaVersion = "0.1.8.2"
55

66
TeaProcessName = "teaweb" // 进程名
77
TeaProductName = "TeaWeb" // 产品名

teautils/command_help.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package teautils
2+
3+
import (
4+
"fmt"
5+
"strconv"
6+
)
7+
8+
// 命令帮助
9+
type CommandHelp struct {
10+
product string
11+
version string
12+
usage string
13+
options []*CommandHelpOption
14+
appendStrings []string
15+
}
16+
17+
func NewCommandHelp() *CommandHelp {
18+
return &CommandHelp{}
19+
}
20+
21+
type CommandHelpOption struct {
22+
Code string
23+
Description string
24+
}
25+
26+
// 产品
27+
func (this *CommandHelp) Product(product string) *CommandHelp {
28+
this.product = product
29+
return this
30+
}
31+
32+
// 版本
33+
func (this *CommandHelp) Version(version string) *CommandHelp {
34+
this.version = version
35+
return this
36+
}
37+
38+
// 使用方法
39+
func (this *CommandHelp) Usage(usage string) *CommandHelp {
40+
this.usage = usage
41+
return this
42+
}
43+
44+
// 选项
45+
func (this *CommandHelp) Option(code string, description string) *CommandHelp {
46+
this.options = append(this.options, &CommandHelpOption{
47+
Code: code,
48+
Description: description,
49+
})
50+
return this
51+
}
52+
53+
// 附加内容
54+
func (this *CommandHelp) Append(appendString string) *CommandHelp {
55+
this.appendStrings = append(this.appendStrings, appendString)
56+
return this
57+
}
58+
59+
// 打印
60+
func (this *CommandHelp) Print() {
61+
fmt.Println(this.product + " v" + this.version)
62+
fmt.Println("Usage:", "\n "+this.usage)
63+
64+
if len(this.options) > 0 {
65+
fmt.Println("")
66+
fmt.Println("Options:")
67+
68+
spaces := 20
69+
max := 40
70+
for _, option := range this.options {
71+
l := len(option.Code)
72+
if l < max && l > spaces {
73+
spaces = l + 4
74+
}
75+
}
76+
77+
for _, option := range this.options {
78+
if len(option.Code) > max {
79+
fmt.Println("")
80+
fmt.Println(" " + option.Code)
81+
option.Code = ""
82+
}
83+
84+
fmt.Printf(" %-"+strconv.Itoa(spaces)+"s%s\n", option.Code, ": "+option.Description)
85+
}
86+
}
87+
88+
if len(this.appendStrings) > 0 {
89+
fmt.Println("")
90+
for _, s := range this.appendStrings {
91+
fmt.Println(s)
92+
}
93+
}
94+
}

teautils/file.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package teautils
2+
3+
import (
4+
"github.com/iwind/TeaGo/Tea"
5+
"path/filepath"
6+
)
7+
8+
// 临时文件
9+
func TmpFile(path string) string {
10+
return filepath.Clean(Tea.Root + Tea.DS + "web" + Tea.DS + "tmp" + Tea.DS + path)
11+
}

teautils/logbuffer/buffer.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,15 @@ func (this *Buffer) Read() (data []byte, err error) {
101101
func (this *Buffer) filename(index int) string {
102102
return this.prefix + "." + strconv.Itoa(index) + ".log"
103103
}
104+
105+
// 关闭
106+
func (this *Buffer) Close() error {
107+
var resultErr error
108+
for _, file := range this.files {
109+
err := file.Close()
110+
if err != nil {
111+
resultErr = err
112+
}
113+
}
114+
return resultErr
115+
}

teautils/os.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

teautils/os_test.go

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)