diff options
author | Andrey Kislyuk <kislyuk@gmail.com> | 2017-07-07 15:31:20 -0700 |
---|---|---|
committer | Andrey Kislyuk <kislyuk@gmail.com> | 2017-07-07 15:31:20 -0700 |
commit | 6f288bfb8ff9969d2489f4c37b608b16ea60ced9 (patch) | |
tree | 369c166b9e9a558718f827a9a2e3511a9a1c47e8 | |
parent | ed80ca333168fa22e6947a99bc6fe37b5b19d2ad (diff) |
Report version via yq --version
-rw-r--r-- | Makefile | 6 | ||||
-rwxr-xr-x | yq/__init__.py | 2 | ||||
-rw-r--r-- | yq/version.py | 1 |
3 files changed, 8 insertions, 1 deletions
@@ -1,6 +1,10 @@ test_deps: pip install .[test] +version: yq/version.py +yq/version.py: setup.py + echo "__version__ = '$$(python setup.py --version)'" > $@ + lint: test_deps ./setup.py flake8 @@ -13,7 +17,7 @@ init_docs: docs: $(MAKE) -C docs html -install: clean +install: clean version pip install wheel python setup.py bdist_wheel pip install --upgrade dist/*.whl diff --git a/yq/__init__.py b/yq/__init__.py index 2bef43a..bd2aa8e 100755 --- a/yq/__init__.py +++ b/yq/__init__.py @@ -11,6 +11,7 @@ import os, sys, argparse, subprocess, json from collections import OrderedDict from datetime import datetime import yaml +from .version import __version__ class Parser(argparse.ArgumentParser): def print_help(self): @@ -47,6 +48,7 @@ parser = Parser(description=__doc__, formatter_class=argparse.RawTextHelpFormatt parser.add_argument("--yaml-output", "--yml-output", "-y", help="Transcode jq JSON output back into YAML and emit it", action="store_true") parser.add_argument("--width", "-w", type=int, help="When using --yaml-output, specify string wrap width") +parser.add_argument("--version", action="version", version="%(prog)s {version}".format(version=__version__)) parser.add_argument("jq_filter") parser.add_argument("file", nargs="*", type=argparse.FileType()) diff --git a/yq/version.py b/yq/version.py new file mode 100644 index 0000000..c57bfd5 --- /dev/null +++ b/yq/version.py @@ -0,0 +1 @@ +__version__ = '0.0.0' |