Skip to content

Commit

Permalink
add --help and --verison (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jul 18, 2020
1 parent 147f099 commit a32fbf7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
17 changes: 12 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ Install :code:`nbqa` with

.. code-block:: bash
pip install nbqa
$ pip install nbqa
Check your installation with

.. code-block:: bash
$ nbqa --version
nbqa 0.1.2
Quickstart
----------
Expand All @@ -52,10 +59,10 @@ For example, you could run:

.. code-block:: bash
nbqa flake8 my_notebook.ipynb
nbqa black my_notebook.ipynb --check
nbqa mypy my_notebook.ipynb --ignore-missing-imports
nbqa pytest my_notebook.ipynb --doctest-modules
$ nbqa flake8 my_notebook.ipynb
$ nbqa black my_notebook.ipynb --check
$ nbqa mypy my_notebook.ipynb --ignore-missing-imports
$ nbqa pytest my_notebook.ipynb --doctest-modules
You can also pass an entire directory instead of a single file, e.g. :code:`nbqa flake8 .`.

Expand Down
20 changes: 16 additions & 4 deletions nbqa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@
from pathlib import Path
from typing import List

from nbqa import put_magics_back_in, replace_magics, replace_source, save_source
from nbqa import (
__version__,
put_magics_back_in,
replace_magics,
replace_source,
save_source,
)


def _parse_args(raw_args):
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="")
parser.add_argument("command")
parser.add_argument("root_dir", default=".", nargs="?")
parser = argparse.ArgumentParser(
description="Adapter to run any code-quality tool on a Jupyter notebook.",
usage="nbqa <command> <notebook or directory> <flags>",
)
parser.add_argument("command", help="Command to run, e.g. `flake8`.")
parser.add_argument(
"root_dir", default=".", nargs="?", help="File or directory to run command on."
)
parser.add_argument("--version", action="version", version=f"nbQA {__version__}")
args, kwargs = parser.parse_known_args(raw_args)
command = args.command
root_dir = args.root_dir
Expand Down

0 comments on commit a32fbf7

Please sign in to comment.