Skip to content

Commit 3568418

Browse files
Merge pull request XmirrorSecurity#285 from SuperChen-CC/master
feat: Add ASCII art logo
2 parents 64d773f + ca82c44 commit 3568418

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

cmd/config/config.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ func WriteConfig(write func(config *Config)) {
7070
// loadDefaultConfig 加载默认配置 返回使用的配置文件
7171
func loadDefaultConfig() string {
7272

73-
defaultConfigPaths := []string{}
73+
var defaultConfigPaths []string
7474

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

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

8585
// 读取 opensca-cli 所在目录下的 config.json
@@ -132,7 +132,10 @@ func RegisterDefaultConfig(data []byte) {
132132
defalutConfigJson = data
133133
if _config == nil {
134134
_config = &Config{}
135-
json5.Unmarshal(defalutConfigJson, &_config)
135+
err := json5.Unmarshal(defalutConfigJson, &_config)
136+
if err != nil {
137+
logs.Warnf("unmarshal default config error: %v", err)
138+
}
136139
}
137140
}
138141

main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ var version string
3030

3131
func main() {
3232

33+
logo := `
34+
___ ____ ____ _
35+
/ _ \ _ __ ___ _ __ / ___| / ___| / \
36+
| | | | '_ \ / _ \ '_ \\___ \| | / _ \
37+
| |_| | |_) | __/ | | |___) | |___ / ___ \
38+
\___/| .__/ \___|_| |_|____/ \____/_/ \_\
39+
|_|`
40+
41+
fmt.Println(logo)
42+
fmt.Println("Current version: ", version)
43+
3344
// 处理参数
3445
args()
3546

0 commit comments

Comments
 (0)