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
This commit is contained in:
parent
3554fdf104
commit
7a29c9094c
|
@ -91,6 +91,7 @@ class Client(zuul.cmd.ZuulApp):
|
||||||
|
|
||||||
cmd_show = subparsers.add_parser('show',
|
cmd_show = subparsers.add_parser('show',
|
||||||
help='valid show subcommands')
|
help='valid show subcommands')
|
||||||
|
cmd_show.set_defaults(func=self.show_running_jobs)
|
||||||
show_subparsers = cmd_show.add_subparsers(title='show')
|
show_subparsers = cmd_show.add_subparsers(title='show')
|
||||||
show_running_jobs = show_subparsers.add_parser(
|
show_running_jobs = show_subparsers.add_parser(
|
||||||
'running-jobs',
|
'running-jobs',
|
||||||
|
@ -108,6 +109,9 @@ class Client(zuul.cmd.ZuulApp):
|
||||||
show_running_jobs.set_defaults(func=self.show_running_jobs)
|
show_running_jobs.set_defaults(func=self.show_running_jobs)
|
||||||
|
|
||||||
self.args = parser.parse_args()
|
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.func == self.enqueue_ref:
|
||||||
if self.args.oldrev == self.args.newrev:
|
if self.args.oldrev == self.args.newrev:
|
||||||
parser.error("The old and new revisions must not be the same.")
|
parser.error("The old and new revisions must not be the same.")
|
||||||
|
|
Loading…
Reference in New Issue