#1157 cli: [make-task] raise readable error when no args
Merged 4 years ago by tkopecek. Opened 5 years ago by julian8628.
julian8628/koji issue/1151  into  master

file modified
+10 -8
@@ -6291,9 +6291,9 @@ 

      watch_logs(session, tasks, options, goptions.poll_interval)

  

  

- def handle_make_task(opts, session, args):

+ def handle_make_task(goptions, session, args):

      "[admin] Create an arbitrary task"

-     usage = _("usage: %prog make-task [options] <arg1> [<arg2>...]")

+     usage = _("usage: %prog make-task [options] <method> [<arg>...]")

      usage += _("\n(Specify the --help global option for a list of other help options)")

      parser = OptionParser(usage=usage)

      parser.add_option("--channel", help=_("set channel"))
@@ -6301,23 +6301,25 @@ 

      parser.add_option("--watch", action="store_true", help=_("watch the task"))

      parser.add_option("--arch", help=_("set arch"))

      (options, args) = parser.parse_args(args)

-     activate_session(session, opts)

+     if len(args) < 1:

+         parser.error(_("Please specify task method at least"))

  

+     activate_session(session, goptions)

      taskopts = {}

-     for key in ('channel','priority','arch'):

-         value = getattr(options,key,None)

+     for key in ('channel', 'priority', 'arch'):

+         value = getattr(options, key, None)

          if value is not None:

              taskopts[key] = value

      task_id = session.makeTask(method=args[0],

-                                arglist=list(map(arg_filter,args[1:])),

+                                arglist=list(map(arg_filter, args[1:])),

                                 **taskopts)

      print("Created task id %d" % task_id)

      if _running_in_bg() or not options.watch:

          return

      else:

          session.logout()

-         return watch_tasks(session, [task_id], quiet=opts.quiet,

-                 poll_interval=opts.poll_interval)

+         return watch_tasks(session, [task_id], quiet=goptions.quiet,

+                 poll_interval=goptions.poll_interval)

  

  

  def handle_tag_build(opts, session, args):

-def handle_make_task(opts, session, args):
+def handle_make_task(goptions, session, args):

Generally speaking, we shouldn't casually change function signatures. Is there any reason for this besides a cosmetic one?

I saw the options argument in most of command handlers have been changed to goptions, so changed this as well

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

4 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-ready

4 years ago

Commit acd51ea fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago