feat: add version command to output current version number
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/engigu/baihu-panel/cmd/resetpwd"
|
"github.com/engigu/baihu-panel/cmd/resetpwd"
|
||||||
"github.com/engigu/baihu-panel/cmd/restore"
|
"github.com/engigu/baihu-panel/cmd/restore"
|
||||||
"github.com/engigu/baihu-panel/cmd/task"
|
"github.com/engigu/baihu-panel/cmd/task"
|
||||||
|
"github.com/engigu/baihu-panel/cmd/version"
|
||||||
"github.com/engigu/baihu-panel/cmd/webui"
|
"github.com/engigu/baihu-panel/cmd/webui"
|
||||||
// "github.com/engigu/baihu-panel/cmd/migrate"
|
// "github.com/engigu/baihu-panel/cmd/migrate"
|
||||||
)
|
)
|
||||||
@@ -21,5 +22,8 @@ var Handlers = map[string]CommandHandler{
|
|||||||
"builtininstall": builtininstall.Run,
|
"builtininstall": builtininstall.Run,
|
||||||
"task": task.Run,
|
"task": task.Run,
|
||||||
"webui": webui.Run,
|
"webui": webui.Run,
|
||||||
|
"version": version.Run,
|
||||||
|
"-v": version.Run,
|
||||||
|
"-V": version.Run,
|
||||||
// "migrate": migrate.Run,
|
// "migrate": migrate.Run,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/engigu/baihu-panel/internal/constant"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Run(args []string) {
|
||||||
|
fmt.Printf("白虎面板 (Baihu Panel) v%s (Build time: %s)\n", constant.Version, constant.BuildTime)
|
||||||
|
}
|
||||||
@@ -32,4 +32,8 @@ var Commands = []CommandInfo{
|
|||||||
Name: "task",
|
Name: "task",
|
||||||
Description: "系统级任务的列表查询、触发运行、启停控制及状态查看",
|
Description: "系统级任务的列表查询、触发运行、启停控制及状态查看",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "version",
|
||||||
|
Description: "查看当前系统版本号 (同 -v, -V)",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if handler, ok := cmd.Handlers[commandName]; ok {
|
if handler, ok := cmd.Handlers[commandName]; ok {
|
||||||
|
if commandName != "-v" && commandName != "-V" && commandName != "version" {
|
||||||
bootstrap.InitBasicForCmd() // 专为命令行工具定制启动基础环境,屏蔽后台启动刷屏日志
|
bootstrap.InitBasicForCmd() // 专为命令行工具定制启动基础环境,屏蔽后台启动刷屏日志
|
||||||
|
}
|
||||||
handler(os.Args[2:])
|
handler(os.Args[2:])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user