From 5546fe57ebe723e2f2cbee5af3a6a31282994447 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Fri, 23 Aug 2024 12:23:19 +0200 Subject: [PATCH] add ~/checkmake.ini as global fallback config --- cmd/checkmake/main.go | 6 ++++++ man/man1/checkmake.1.md | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/checkmake/main.go b/cmd/checkmake/main.go index 3256adf..04de632 100644 --- a/cmd/checkmake/main.go +++ b/cmd/checkmake/main.go @@ -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) diff --git a/man/man1/checkmake.1.md b/man/man1/checkmake.1.md index 9e3c24e..ee90197 100644 --- a/man/man1/checkmake.1.md +++ b/man/man1/checkmake.1.md @@ -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: