Skip to content

Commit

Permalink
Merge pull request #285 from SuperChen-CC/master
Browse files Browse the repository at this point in the history
feat: Add ASCII art logo
  • Loading branch information
cyberchen1995 authored Apr 1, 2024
2 parents 64d773f + ca82c44 commit 3568418
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ func WriteConfig(write func(config *Config)) {
// loadDefaultConfig 加载默认配置 返回使用的配置文件
func loadDefaultConfig() string {

defaultConfigPaths := []string{}
var defaultConfigPaths []string

// 读取工作目录的 config.json
if p, err := os.Getwd(); err == nil {
defaultConfigPaths = append(defaultConfigPaths, filepath.Join(p, "config.json"))
}

// 读取用户目录下的 opensca_config.json
if user, err := user.Current(); err == nil {
defaultConfigPaths = append(defaultConfigPaths, filepath.Join(user.HomeDir, "opensca_config.json"))
if currenUser, err := user.Current(); err == nil {
defaultConfigPaths = append(defaultConfigPaths, filepath.Join(currenUser.HomeDir, "opensca_config.json"))
}

// 读取 opensca-cli 所在目录下的 config.json
Expand Down Expand Up @@ -132,7 +132,10 @@ func RegisterDefaultConfig(data []byte) {
defalutConfigJson = data
if _config == nil {
_config = &Config{}
json5.Unmarshal(defalutConfigJson, &_config)
err := json5.Unmarshal(defalutConfigJson, &_config)
if err != nil {
logs.Warnf("unmarshal default config error: %v", err)
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ var version string

func main() {

logo := `
___ ____ ____ _
/ _ \ _ __ ___ _ __ / ___| / ___| / \
| | | | '_ \ / _ \ '_ \\___ \| | / _ \
| |_| | |_) | __/ | | |___) | |___ / ___ \
\___/| .__/ \___|_| |_|____/ \____/_/ \_\
|_|`

fmt.Println(logo)
fmt.Println("Current version: ", version)

// 处理参数
args()

Expand Down

0 comments on commit 3568418

Please sign in to comment.