Skip to content

Commit

Permalink
add ~/checkmake.ini as global fallback config
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Aug 23, 2024
1 parent bd26d79 commit 5546fe5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions cmd/checkmake/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ func parseArgsAndGetFormatter(args map[string]interface{}) (formatters.Formatter

if args["--config"] != nil {
configPath = args["--config"].(string)
} else {
_, err := os.Stat(configPath);
if os.IsNotExist(err) {
home := os.Getenv("HOME")
configPath = home + "/checkmake.ini"
}
}

cfg, cfgError := config.NewConfigFromFile(configPath)
Expand Down
14 changes: 8 additions & 6 deletions man/man1/checkmake.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ configurable rules being run against a Makefile or a set of `\*.mk` files.
: List registered rules

# CONFIGURATION
By default checkmake looks for a `checkmake.ini` file in the same folder it's
executed in. This can be overridden by passing the `--config=` argument
pointing it to a different configuration file. With the configuration file
the `[default]` section is for checkmake itself while sections named after the
rule names are passed to the rules as their configuration. All keys/values are
hereby treated as strings and passed to the rule in a string/string map.
By default checkmake looks for a `checkmake.ini` file in the same
folder it's executed in, and then as fallback in `~/checkmake.ini`.
This can be overridden by passing the `--config=` argument pointing it
to a different configuration file. With the configuration file the
`[default]` section is for checkmake itself while sections named after
the rule names are passed to the rules as their configuration. All
keys/values are hereby treated as strings and passed to the rule in a
string/string map.

The following configuration options for checkmake itself are supported within
the `default` section:
Expand Down

0 comments on commit 5546fe5

Please sign in to comment.