Skip to content

Commit

Permalink
cli: add --version flag (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotmax23 authored Feb 14, 2024
1 parent 40341ed commit 0232c1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/147-version-option.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- "Add ``--version`` flag to print package version and exit
(https://github.com/ansible-community/antsibull-changelog/pull/147)."
2 changes: 2 additions & 0 deletions src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
except ImportError:
HAS_ARGCOMPLETE = False

from . import __version__ as _version
from .ansible import get_ansible_release
from .changes import ChangesBase, add_release, load_changes
from .config import ChangelogConfig, CollectionDetails, PathsConfig, TextFormat
Expand Down Expand Up @@ -113,6 +114,7 @@ def create_argparser(program_name: str) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog=program_name, description="Changelog generator and linter."
)
parser.add_argument("--version", action="version", version=_version)

common = argparse.ArgumentParser(add_help=False)
common.add_argument(
Expand Down

0 comments on commit 0232c1e

Please sign in to comment.