Skip to content

Commit

Permalink
Document environment variables (#3833)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Oct 11, 2023
1 parent c3af71f commit 9ec6f59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ansiblelint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
11 changes: 11 additions & 0 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9ec6f59

Please sign in to comment.