Add --version option

Adds the option to query the (pbr generated) version string

Change-Id: Ia8a19602802a1da1029f8e575dafcafcca87388a
This commit is contained in:
Steven Hardy 2014-10-27 17:08:56 +00:00
parent 0b71572687
commit 71ac3c6c5e
2 changed files with 24 additions and 2 deletions

View File

@ -0,0 +1,16 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import pbr.version
__version__ = pbr.version.VersionInfo('python-tuskarclient').version_string()

View File

@ -23,6 +23,7 @@ import sys
import six import six
import tuskarclient
from tuskarclient import client from tuskarclient import client
import tuskarclient.common.utils as utils import tuskarclient.common.utils as utils
from tuskarclient.openstack.common.apiclient import exceptions as exc from tuskarclient.openstack.common.apiclient import exceptions as exc
@ -68,8 +69,8 @@ class TuskarShell(object):
self._ensure_auth_info(args) self._ensure_auth_info(args)
tuskar_client = client.get_client(self.partial_args.tuskar_api_version, tuskar_client = client.get_client(
**args.__dict__) self.partial_args.tuskar_api_version, **args.__dict__)
args.func(tuskar_client, args) args.func(tuskar_client, args)
def _ensure_auth_info(self, args): def _ensure_auth_info(self, args):
@ -134,6 +135,11 @@ class TuskarShell(object):
help="Print this help message and exit.", help="Print this help message and exit.",
) )
parser.add_argument('--version',
action='version',
version=tuskarclient.__version__,
help="Shows the client version and exits.")
parser.add_argument('--os-username', parser.add_argument('--os-username',
default=utils.env('OS_USERNAME'), default=utils.env('OS_USERNAME'),
help='Defaults to env[OS_USERNAME]', help='Defaults to env[OS_USERNAME]',