Skip to content

Commit

Permalink
优化 windows console
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Mar 1, 2023
1 parent 4dc8378 commit 84115a7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
2 changes: 2 additions & 0 deletions console/console.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package console sets console's behavior on init
package console
12 changes: 10 additions & 2 deletions main_windows.go → console/console_windows.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package main
package console

import (
"bytes"
"golang.org/x/sys/windows"
"os"
"strings"

"golang.org/x/sys/windows"

"github.com/sirupsen/logrus"

"github.com/FloatTech/ZeroBot-Plugin/kanban"
)

func init() {
Expand Down Expand Up @@ -50,6 +53,11 @@ func init() {
}
// windows 带颜色 log 自定义格式
logrus.SetFormatter(&LogFormat{})

err = windows.SetConsoleTitle("ZeroBot-Blugin " + kanban.Version + " " + kanban.Copyright)
if err != nil {
panic(err)
}
}

const (
Expand Down
11 changes: 8 additions & 3 deletions kanban/banner.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions kanban/gen/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ import (
"time"
)

const banner = `package kanban
const banner = `// Code generated by kanban/gen. DO NOT EDIT.
package kanban
// Version ...
var Version = "%s"
// Copyright ...
var Copyright = "© 2020 - %d FloatTech"
// Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version " + Version + " - %s\n" +
"* Copyright © 2020 - %d FloatTech. All Rights Reserved.\n" +
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
`

Expand All @@ -39,7 +44,7 @@ func main() {
}
s := strings.Split(vartag.String(), "\n")
now := time.Now()
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Format(timeformat), now.Year())
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Year(), now.Format(timeformat))
if err != nil {
panic(err)
}
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (

"github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner

_ "github.com/FloatTech/ZeroBot-Plugin/console" // 更改控制台属性

// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
// ----------------------插件优先级按顺序从高到低---------------------- //
// //
Expand Down
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=auto
go mod tidy
::go build -ldflags="-s -w" -o ZeroBot-Plugin.exe
go run main.go main_windows.go
go run main.go
pause
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=auto
go mod tidy
#go build -ldflags="-s -w" -o ZeroBot-Plugin
go run main.go
go run main.go

0 comments on commit 84115a7

Please sign in to comment.