commit:     807bb140b51eb75ac25474ff76577b09be04b1d1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  8 03:42:26 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  8 03:42:26 2015 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=807bb140

gkeys, gkeys-gen: Add --version option

---
 gkeys-gen/gkeygen/__init__.py | 2 +-
 gkeys-gen/gkeygen/cli.py      | 2 ++
 gkeys/gkeys/__init__.py       | 2 +-
 gkeys/gkeys/base.py           | 3 +++
 gkeys/gkeys/cli.py            | 2 ++
 py2man/command.template       | 2 +-
 py2man/options.py             | 2 ++
 7 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gkeys-gen/gkeygen/__init__.py b/gkeys-gen/gkeygen/__init__.py
index e990779..ea87b6a 100644
--- a/gkeys-gen/gkeygen/__init__.py
+++ b/gkeys-gen/gkeygen/__init__.py
@@ -15,7 +15,7 @@ for cmd in Available_Actions:
     subdata[cmd] = Action_Map[cmd]['desc']
 
 Gkeys_Map = {
-    'options': ['help', 'config', 'debug'],
+    'options': ['help', 'config', 'debug', 'version'],
     'desc': 'OpenPGP/GPG key generator tool',
     'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to 
manage
 the GPG keys used for validation on users and Gentoo's infrastracutre servers.

diff --git a/gkeys-gen/gkeygen/cli.py b/gkeys-gen/gkeygen/cli.py
index 561bf9f..f522814 100644
--- a/gkeys-gen/gkeygen/cli.py
+++ b/gkeys-gen/gkeygen/cli.py
@@ -7,6 +7,7 @@ from __future__ import print_function
 import os
 import sys
 
+from gkeys import __version__
 from gkeys.config import GKeysConfig
 from gkeys.base import CliBase
 from gkeygen.actions import Actions, Available_Actions, Action_Map
@@ -35,6 +36,7 @@ class Main(CliBase):
             'description': 'Gentoo Keys GPG key generator program',
             'epilog': '''CAUTION: adding UNTRUSTED keys can be HAZARDOUS to 
your system!'''
         }
+        self.version = __version__
 
 
     def __call__(self, args=None):

diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py
index 503d359..d148872 100644
--- a/gkeys/gkeys/__init__.py
+++ b/gkeys/gkeys/__init__.py
@@ -17,7 +17,7 @@ for cmd in Available_Actions:
     subdata[cmd] = Action_Map[cmd]['desc']
 
 Gkeys_Map = {
-    'options': ['help', 'config', 'debug'],
+    'options': ['help', 'config', 'debug', 'version'],
     'desc': 'OpenPGP/GPG key management tool',
     'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to 
manage
 the GPG keys used for validation on users and Gentoo's infrastracutre servers.

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 65ad9cc..46f8f2f 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -44,6 +44,7 @@ class CliBase(object):
         self.seeds = None
         self.actions = None
         self.logger = None
+        self.version = None
 
 
     @staticmethod
@@ -209,6 +210,8 @@ class CliBase(object):
         parser.add_argument('-D', '--debug', default='DEBUG',
             choices=list(log_levels),
             help='The logging level to set for the logfile')
+        parser.add_argument('-V', '--version', action = 'version',
+                          version = self.version)
 
 
         subparsers = parser.add_subparsers(

diff --git a/gkeys/gkeys/cli.py b/gkeys/gkeys/cli.py
index 8ec45f9..194afd2 100644
--- a/gkeys/gkeys/cli.py
+++ b/gkeys/gkeys/cli.py
@@ -16,6 +16,7 @@ from __future__ import print_function
 import os
 import sys
 
+from gkeys import __version__
 from gkeys.base import CliBase
 from gkeys.actions import Actions
 from gkeys.action_map import Available_Actions, Action_Map
@@ -44,6 +45,7 @@ class Main(CliBase):
             'description': 'Gentoo-keys manager program',
             'epilog': '''CAUTION: adding UNTRUSTED keys can be HAZARDOUS to 
your system!'''
         }
+        self.version = __version__
 
 
     def __call__(self, args=None):

diff --git a/py2man/command.template b/py2man/command.template
index 975a4bf..7b44506 100644
--- a/py2man/command.template
+++ b/py2man/command.template
@@ -4,7 +4,7 @@
 
 .SH SYNOPSIS
 .B %(prog)s
-[\fB\-h\fR] [\fB\-c\fR \fICONFIG\fR] [\fB\-D\fR 
\fI{WARNING,INFO,FATAL,NOTSET,WARN,DEBUG,ERROR,CRITICAL}\fR] [\fBSUBCOMMAND] 
[\fBSUBCOMMAND-OPTION] ...
+[\fB\-h\fR] [\fB\-c\fR \fICONFIG\fR] [\fB\-D\fR 
\fI{WARNING,INFO,FATAL,NOTSET,WARN,DEBUG,ERROR,CRITICAL}\fR] 
[\fB\-V\fR][\fBSUBCOMMAND] [\fBSUBCOMMAND-OPTION] ...
 
 .SH DESCRIPTION
 .PP

diff --git a/py2man/options.py b/py2man/options.py
index 87d19bf..61a6230 100644
--- a/py2man/options.py
+++ b/py2man/options.py
@@ -64,6 +64,8 @@ The spec file to use from the gkeys-gen.conf file.''',
 Turn on timestamp use.''',
     'uid': '''.IP "-u \\fIUID\\fR, --uid \\fIUID"
 The user id(s) (and email) of the key(s) being added (optional)''',
+    'version': '''.IP "-V, --version"
+The program version''',
 })
 
 SHORT_OPTS = OrderedDict({

Reply via email to