Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ~/checkmake.ini as global fallback config #104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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