diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py index 8f55c3df7e..a334bff19d 100644 --- a/zuul/cmd/client.py +++ b/zuul/cmd/client.py @@ -39,7 +39,8 @@ class Client(object): help='specify the config file') parser.add_argument('-v', dest='verbose', action='store_true', help='verbose output') - parser.add_argument('--version', dest='version', action='store_true', + parser.add_argument('--version', dest='version', action='version', + version=self._get_version(), help='show zuul version') subparsers = parser.add_subparsers(title='commands', @@ -67,6 +68,10 @@ class Client(object): self.args = parser.parse_args() + def _get_version(self): + from zuul.version import version_info as zuul_version_info + return "Zuul version: %s" % zuul_version_info.version_string() + def read_config(self): self.config = ConfigParser.ConfigParser() if self.args.config: @@ -89,11 +94,6 @@ class Client(object): self.read_config() self.setup_logging() - if self.args.version: - from zuul.version import version_info as zuul_version_info - print "Zuul version: %s" % zuul_version_info.version_string() - sys.exit(0) - self.server = self.config.get('gearman', 'server') if self.config.has_option('gearman', 'port'): self.port = self.config.get('gearman', 'port') diff --git a/zuul/cmd/server.py b/zuul/cmd/server.py index c2a9dab0a9..79015359f0 100755 --- a/zuul/cmd/server.py +++ b/zuul/cmd/server.py @@ -66,10 +66,15 @@ class Server(object): help='validate layout file syntax (optionally ' 'providing the path to a file with a list of ' 'available job names)') - parser.add_argument('--version', dest='version', action='store_true', + parser.add_argument('--version', dest='version', action='version', + version=self._get_version(), help='show zuul version') self.args = parser.parse_args() + def _get_version(self): + from zuul.version import version_info as zuul_version_info + return "Zuul version: %s" % zuul_version_info.version_string() + def read_config(self): self.config = ConfigParser.ConfigParser() if self.args.config: @@ -227,11 +232,6 @@ def main(): server = Server() server.parse_arguments() - if server.args.version: - from zuul.version import version_info as zuul_version_info - print "Zuul version: %s" % zuul_version_info.version_string() - sys.exit(0) - server.read_config() if server.args.layout: