diff --git a/src/ansiblelint/cli.py b/src/ansiblelint/cli.py index d295d517c4..c30c1f0d71 100644 --- a/src/ansiblelint/cli.py +++ b/src/ansiblelint/cli.py @@ -16,7 +16,7 @@ Options, log_entries, ) -from ansiblelint.constants import CUSTOM_RULESDIR_ENVVAR, DEFAULT_RULESDIR, RC +from ansiblelint.constants import CUSTOM_RULESDIR_ENVVAR, DEFAULT_RULESDIR, EPILOG, RC from ansiblelint.file_utils import ( Lintable, abspath, @@ -240,7 +240,11 @@ def merge_fix_list_config( def get_cli_parser() -> argparse.ArgumentParser: """Initialize an argument parser.""" - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser( + epilog=EPILOG, + # Avoid rewrapping description and epilog + formatter_class=argparse.RawTextHelpFormatter, + ) listing_group = parser.add_mutually_exclusive_group() listing_group.add_argument( diff --git a/src/ansiblelint/constants.py b/src/ansiblelint/constants.py index 2b663e5247..4b146476a9 100644 --- a/src/ansiblelint/constants.py +++ b/src/ansiblelint/constants.py @@ -7,6 +7,17 @@ CUSTOM_RULESDIR_ENVVAR = "ANSIBLE_LINT_CUSTOM_RULESDIR" RULE_DOC_URL = "https://ansible-lint.readthedocs.io/rules/" +ENV_VARS_HELP = { + CUSTOM_RULESDIR_ENVVAR: "Used for adding another folder into the lookup path for new rules.", + "ANSIBLE_LINT_IGNORE_FILE": "Define it to override the name of the default ignore file `.ansible-lint-ignore`", + "ANSIBLE_LINT_WRITE_TMP": "Tells linter to dump fixes into different temp files instead of overriding original. Used internally for testing.", +} + +EPILOG = ( + "The following environment variables are also recognized but there is no guarantee that they will work in future versions:\n\n" + + "\n".join(f"{key}: {value}\n" for key, value in ENV_VARS_HELP.items()) +) + # Not using an IntEnum because only starting with py3.11 it will evaluate it # as int.