Skip to content

Commit 9a9d488

Browse files
fix: in main add parsing of file again
1 parent d99271c commit 9a9d488

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

.codacy/codacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ tools:
55
66
77
8-
8+

cli-v2.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,24 @@ package main
22

33
import (
44
"codacy/cli-v2/cmd"
5+
"codacy/cli-v2/config"
6+
config_file "codacy/cli-v2/config-file"
7+
"fmt"
8+
"os"
59
)
610

711
func main() {
12+
// Initialize config global object
13+
config.Init()
14+
15+
// This also setup the config global !
16+
configErr := config_file.ReadConfigFile(config.Config.ProjectConfigFile())
17+
18+
// whenever there is no configuration file, the only command allowed to run is the 'init'
19+
if configErr != nil && len(os.Args) > 1 && os.Args[1] != "init" {
20+
fmt.Println("No configuration file was found, execute init command first.")
21+
return
22+
}
823

924
cmd.Execute()
1025
}

cmd/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ tools:
9898
- eslint@%s
9999
- trivy@%s
100100
- pylint@%s
101-
- pmd@%s
101+
- pmd@%s
102102
`, eslintVersion, trivyVersion, pylintVersion, pmdVersion)
103103
}
104104

cmd/install.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ var installCmd = &cobra.Command{
3030
bold := color.New(color.Bold)
3131
green := color.New(color.FgGreen)
3232

33-
// Initialize config global object
34-
cfg.Init()
35-
3633
// Load config file
3734
if err := config_file.ReadConfigFile(cfg.Config.ProjectConfigFile()); err != nil {
3835
fmt.Println()

0 commit comments

Comments
 (0)