Skip to content

Commit 359d205

Browse files
allow for showing help without codacy conf
1 parent 9b11b2b commit 359d205

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

cli-v2.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,22 @@ func main() {
1515
// This also setup the config global !
1616
configErr := config_file.ReadConfigFile(config.Config.ProjectConfigFile())
1717

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" {
18+
// Show help if any argument contains help
19+
for _, arg := range os.Args {
20+
if arg == "--help" || arg == "-h" || arg == "help" {
21+
cmd.Execute()
22+
return
23+
}
24+
}
25+
26+
// Check if command is init
27+
if len(os.Args) > 1 && os.Args[1] == "init" {
28+
cmd.Execute()
29+
return
30+
}
31+
32+
// All other commands require a configuration file
33+
if configErr != nil && len(os.Args) > 1 {
2034
fmt.Println("No configuration file was found, execute init command first.")
2135
return
2236
}

0 commit comments

Comments
 (0)