diff --git a/README.rst b/README.rst index 80efe9f..4a1893d 100644 --- a/README.rst +++ b/README.rst @@ -64,6 +64,7 @@ Changelog * JPEG optimization has been improved by using some optimizations from MozJPEG after the Guetzli encoding (from 2.4 % to 7.3 % of additional size reduction) + * CLI: add a ``--version`` option to get YOGA's version * **For packagers:** * new dependency to `mozjpeg-lossless-optimization diff --git a/doc/cli/index.rst b/doc/cli/index.rst index 2de21d2..b234780 100644 --- a/doc/cli/index.rst +++ b/doc/cli/index.rst @@ -12,6 +12,7 @@ Command Line Interface optional arguments: -h, --help show this help message and exit + --version show program's version number and exit The YOGA command line interface is divided in two sub-commands: diff --git a/yoga/cli.py b/yoga/cli.py index a4a7246..15cc0f1 100644 --- a/yoga/cli.py +++ b/yoga/cli.py @@ -4,6 +4,7 @@ from functools import partial from .image.cli import add_image_cli_options from .model.cli import add_model_cli_options +from .version import VERSION def _type_path(mode, string): @@ -71,6 +72,12 @@ def generate_main_cli(): prog="yoga", usage="%(prog)s [-h] {image,model} [options...] input output", ) + parser.add_argument( + "--version", + action="version", + version="%%(prog)s %s" % VERSION, + ) + subparsers = parser.add_subparsers(dest="subcommand") image_parser = subparsers.add_parser( diff --git a/yoga/version.py b/yoga/version.py new file mode 100644 index 0000000..3277f64 --- /dev/null +++ b/yoga/version.py @@ -0,0 +1 @@ +VERSION = "1.0.0"