Skip to content

Commit

Permalink
feat: Add --version and -V cli flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarte committed Jul 25, 2023
1 parent 1e7b869 commit 78d56a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/griffe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from griffe.loader import load
from griffe.logger import get_logger

# For acceptable version formats, see https://www.python.org/dev/peps/pep-0440/
__version__ = '0.32.3'

__all__: list[str] = [
"Attribute",
"Class",
Expand All @@ -32,3 +35,4 @@
"Object",
"ObjectNode",
]

2 changes: 2 additions & 0 deletions src/griffe/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import colorama

from griffe import __version__
from griffe.diff import ExplanationStyle, find_breaking_changes
from griffe.docstrings.parsers import Parser
from griffe.encoders import JSONEncoder
Expand Down Expand Up @@ -122,6 +123,7 @@ def get_parser() -> argparse.ArgumentParser:

global_options = parser.add_argument_group(title="Global options")
global_options.add_argument("-h", "--help", action="help", help=main_help)
global_options.add_argument("-V", "--version", action="version", version=f'%(prog)s ' + __version__)

def add_common_options(subparser: argparse.ArgumentParser) -> None:
common_options = subparser.add_argument_group(title="Common options")
Expand Down

0 comments on commit 78d56a7

Please sign in to comment.