diff --git a/changelogs/fragments/147-version-option.yaml b/changelogs/fragments/147-version-option.yaml new file mode 100644 index 00000000..53a6e7dd --- /dev/null +++ b/changelogs/fragments/147-version-option.yaml @@ -0,0 +1,4 @@ +--- +minor_changes: + - "Add ``--version`` flag to print package version and exit + (https://github.com/ansible-community/antsibull-changelog/pull/147)." diff --git a/src/antsibull_changelog/cli.py b/src/antsibull_changelog/cli.py index 49c0e181..30e115dd 100644 --- a/src/antsibull_changelog/cli.py +++ b/src/antsibull_changelog/cli.py @@ -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 @@ -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(