Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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