Skip to content

Commit

Permalink
feat: set CLI options with environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoliwa committed Nov 11, 2023
1 parent 38102c9 commit 3575b9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 1 addition & 4 deletions docs/cli.rst
Expand Up @@ -5,10 +5,6 @@
Command-line interface
======================

.. note::

The CLI is experimental, still under active development.

Nitpick_ has a CLI command to fix files automatically.

1. It doesn't work for all the plugins yet. Currently, it works for:
Expand All @@ -21,6 +17,7 @@ Nitpick_ has a CLI command to fix files automatically.
4. Run ``nitpick fix`` to modify files directly, or ``nitpick check`` to only display the violations.
5. The flake8_ plugin only checks the files and doesn't make changes. This is the default for now; once the CLI becomes more stable, the "fix mode" will become the default.
6. The output format aims to follow `pycodestyle (pep8) default output format <https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py#L108>`_.
7. You can set options through environment variables using the format ``NITPICK_command_option``. E.e: ``NITPICK_CHECK_VERBOSE=3 nitpick check``. For more details on how this works, see the `Click documentation about CLI options <https://click.palletsprojects.com/en/8.1.x/options/#values-from-environment-variables>`_.

If you use Git, you can review the files before committing.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -111,7 +111,7 @@ toml = "nitpick.plugins.toml"
yaml = "nitpick.plugins.yaml"

[tool.poetry.scripts]
nitpick = "nitpick.cli:nitpick_cli"
nitpick = "nitpick.__main__:main"

[tool.poetry.urls]
"Changelog" = "https://github.com/andreoliwa/nitpick/blob/develop/CHANGELOG.md"
Expand Down
9 changes: 8 additions & 1 deletion src/nitpick/__main__.py
Expand Up @@ -7,6 +7,13 @@
"""
# pragma: no cover
from nitpick.cli import nitpick_cli
from nitpick.constants import PROJECT_NAME


def main() -> None:
"""Entry point for the application script."""
nitpick_cli(auto_envvar_prefix=PROJECT_NAME)


if __name__ == "__main__":
nitpick_cli()
main()

0 comments on commit 3575b9a

Please sign in to comment.