From c54ce9416d7c0f3423be34ca7164450bd972c22c Mon Sep 17 00:00:00 2001 From: Josh Temple <8672171+joshtemple@users.noreply.github.com> Date: Tue, 21 Jan 2020 22:38:51 -0500 Subject: [PATCH] Add command to print version Uses a top-level defined variable __version__ which is imported into setup.py and used in the CLI with the --version argument. --- setup.py | 3 +-- spectacles/__init__.py | 1 + spectacles/cli.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index dc0b1fb8..dae5e86b 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ from pathlib import Path from setuptools import setup, find_packages - -__version__ = "0.1.1" +from spectacles import __version__ here = Path(__file__).parent.resolve() diff --git a/spectacles/__init__.py b/spectacles/__init__.py index e69de29b..485f44ac 100644 --- a/spectacles/__init__.py +++ b/spectacles/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.1" diff --git a/spectacles/cli.py b/spectacles/cli.py index 95d5e1f7..6f7fb37b 100644 --- a/spectacles/cli.py +++ b/spectacles/cli.py @@ -6,6 +6,7 @@ import logging import os from typing import Callable +from spectacles import __version__ from spectacles.runner import Runner from spectacles.client import LookerClient from spectacles.exceptions import SpectaclesException, ValidationError @@ -223,6 +224,7 @@ def create_parser() -> argparse.ArgumentParser: """ parser = argparse.ArgumentParser(prog="spectacles") + parser.add_argument("--version", action="version", version=__version__) subparser_action = parser.add_subparsers( title="Available sub-commands", dest="command" )