From 7a29c9094c3eaad91363470fd9f5884a002c19e3 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Mon, 17 Jul 2017 08:04:07 +0000 Subject: [PATCH] Fix zuul command default function When running the zuul command without arguments it fails with AttributeError 'Namespace' object has no attribute 'func'. This change prints the usage() when no argument are used and also sets the default show sub command to running_jobs. Change-Id: I47c8b4c32a8ce9bdcfeca6719a03794feab477f0 --- zuul/cmd/client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py index dec15e756f..b55aed80a3 100755 --- a/zuul/cmd/client.py +++ b/zuul/cmd/client.py @@ -91,6 +91,7 @@ class Client(zuul.cmd.ZuulApp): cmd_show = subparsers.add_parser('show', help='valid show subcommands') + cmd_show.set_defaults(func=self.show_running_jobs) show_subparsers = cmd_show.add_subparsers(title='show') show_running_jobs = show_subparsers.add_parser( 'running-jobs', @@ -108,6 +109,9 @@ class Client(zuul.cmd.ZuulApp): show_running_jobs.set_defaults(func=self.show_running_jobs) self.args = parser.parse_args() + if not getattr(self.args, 'func', None): + parser.print_help() + sys.exit(1) if self.args.func == self.enqueue_ref: if self.args.oldrev == self.args.newrev: parser.error("The old and new revisions must not be the same.")