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
changes/79/484279/1
Tristan Cacqueray 6 years ago
parent 3554fdf104
commit 7a29c9094c

@ -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.")

Loading…
Cancel
Save