golib/console/cli_about.go

60 lines
1.2 KiB
Go
Raw Normal View History

2023-06-15 21:22:51 +08:00
//
// cli_about.go
// Copyright (C) 2022 tiglog <me@tiglog.com>
//
// Distributed under terms of the MIT license.
//
package console
import (
"fmt"
"path/filepath"
"runtime"
)
type cAbout struct {
BaseCmd
cli IConsole
}
func NewAboutCmd(cli IConsole) *cAbout {
c := new(cAbout)
c.Name = "about"
c.Desc = "应用基本环境"
c.cli = cli
return c
}
func (c *cAbout) Init(args []string) {
c.Action = func() error {
fmt.Printf("About:\n")
fmt.Printf("==================================================\n")
2023-09-19 15:14:14 +08:00
fmt.Printf(" Version: %s\n", c.cli.GetVersion())
2023-06-15 21:22:51 +08:00
wd, _ := filepath.Abs("./")
2023-09-19 15:14:14 +08:00
fmt.Printf(" BaseDir: %s\n", wd)
fmt.Printf(" Env: %s\n", "dev")
fmt.Printf(" Debug: %v\n", true)
fmt.Printf(" GOOS: %s %s\n", runtime.GOOS, runtime.GOARCH)
2023-06-15 21:22:51 +08:00
hd := c.cli.GetExtraAbout()
if hd != nil {
return hd()
}
// if sqldb.Db != nil {
// fmt.Printf(" Db Type: %s\n", config.Conf.Db.Type)
// fmt.Printf(" Db Host: %s\n", config.Conf.Db.Host)
// fmt.Printf(" Db Port: %d\n", config.Conf.Db.Port)
// fmt.Printf(" Db Name: %s\n", config.Conf.Db.Name)
// fmt.Printf(" Db User: %s\n", config.Conf.Db.Username)
// }
return nil
}
}
func (c *cAbout) GetHelp() string {
return ""
}