main: add a --version argument

This adds a `osbuild --version` command that prints the current osbuild
version in use. Allows users to confirm their osbuild is up to date
enough to use newer features.
This commit is contained in:
Simon de Vlieger 2022-06-22 13:02:14 +02:00 committed by Christian Kellner
parent ace6c3524b
commit 5c25f17ab7
3 changed files with 9 additions and 1 deletions

View file

@ -301,3 +301,4 @@ bump-version:
sed -i "s|Version:\(\s*\)$(VERSION)|Version:\1$(NEXT_VERSION)|" osbuild.spec
sed -i "s|Release:\(\s*\)[[:digit:]]\+|Release:\11|" osbuild.spec
sed -i "s|version=\"$(VERSION)\"|version=\"$(NEXT_VERSION)\"|" setup.py
sed -i "s|__version__ = \"$(VERSION)\"|__version__ = \"$(NEXT_VERSION)\"|" osbuild/__init__.py

View file

@ -11,8 +11,11 @@ independent of osbuild but used across the osbuild codebase.
from .pipeline import Manifest, Pipeline, Stage
__version__ = "60"
__all__ = [
"Manifest",
"Pipeline",
"Stage",
"__version__",
]

View file

@ -61,7 +61,8 @@ def export(name_or_id, output_directory, store, manifest):
def parse_arguments(sys_argv):
parser = argparse.ArgumentParser(description="Build operating system images")
parser = argparse.ArgumentParser(prog="osbuild",
description="Build operating system images")
parser.add_argument("manifest_path", metavar="MANIFEST",
help="json file containing the manifest that should be built, or a '-' to read from stdin")
@ -86,6 +87,9 @@ def parse_arguments(sys_argv):
help="File descriptor to be used for the monitor")
parser.add_argument("--stage-timeout", type=int, default=None,
help="set the maximal time (in seconds) each stage is allowed to run")
parser.add_argument("--version", action="version",
help="return the version of osbuild",
version="%(prog)s " + osbuild.__version__)
return parser.parse_args(sys_argv[1:])