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:

  1. It tries to preserve the comments and the formatting of the original file.

  2. Some changes still have to be done manually; Nitpick cannot guess how to make certain changes automatically.

  3. Run nitpick fix to modify files directly, or nitpick check to only display the violations.

  4. 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.

  5. The output format aims to follow pycodestyle (pep8) default output format.

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

The available commands are described below.

Main options

Usage: nitpick [OPTIONS] COMMAND [ARGS]...

  Enforce the same settings across multiple language-independent projects.

Options:
  -p, --project DIRECTORY  Path to project root
  --offline                Offline mode: no style will be downloaded (no HTTP
                           requests at all)
  --version                Show the version and exit.
  --help                   Show this message and exit.

Commands:
  check  Don't modify files, just print the differences.
  fix    Fix files, modifying them directly.
  init   Create a [tool.nitpick] section in the configuration file if it...
  ls     List of files configured in the Nitpick style.

fix: Modify files directly

At the end of execution, this command displays:

  • the number of fixed violations;

  • the number of violations that have to be changed manually.

Usage: nitpick fix [OPTIONS] [FILES]...

  Fix files, modifying them directly.

  You can use partial and multiple file names in the FILES argument.

Options:
  -v, --verbose  Increase logging verbosity (-v = INFO, -vv = DEBUG)
  --help         Show this message and exit.

check: Don’t modify, just print the differences

Usage: nitpick check [OPTIONS] [FILES]...

  Don't modify files, just print the differences.

  Return code 0 means nothing would change. Return code 1 means some files
  would be modified. You can use partial and multiple file names in the FILES
  argument.

Options:
  -v, --verbose  Increase logging verbosity (-v = INFO, -vv = DEBUG)
  --help         Show this message and exit.

ls: List configures files

Usage: nitpick ls [OPTIONS] [FILES]...

  List of files configured in the Nitpick style.

  Display existing files in green and absent files in red. You can use partial
  and multiple file names in the FILES argument.

Options:
  --help  Show this message and exit.

init: Initialise a configuration file

Usage: nitpick init [OPTIONS] [STYLE_URLS]...

  Create a [tool.nitpick] section in the configuration file if it doesn't
  exist already.

Options:
  --help  Show this message and exit.