gnt-job list: Add option to include archived jobs
authorMichael Hanselmann <hansmi@google.com>
Thu, 11 Oct 2012 08:58:28 +0000 (10:58 +0200)
committerMichael Hanselmann <hansmi@google.com>
Thu, 11 Oct 2012 09:23:55 +0000 (11:23 +0200)
This provides a convenience option to include archived jobs in the
output list. It's equivalent to using “-o +archived”, but tab completion
is nicer.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/client/gnt_job.py
man/gnt-job.rst

index 78eec77..3bdbd0d 100644 (file)
@@ -87,6 +87,9 @@ def ListJobs(opts, args):
   """
   selected_fields = ParseFields(opts.output, _LIST_DEF_FIELDS)
 
+  if opts.archived and "archived" not in selected_fields:
+    selected_fields.append("archived")
+
   fmtoverride = {
     "status": (_FormatStatus, False),
     "summary": (lambda value: ",".join(str(item) for item in value), False),
@@ -387,12 +390,17 @@ _FINISHED_OPT = \
              const=constants.JOBS_FINALIZED,
              help="Show finished jobs only")
 
+_ARCHIVED_OPT = \
+  cli_option("--archived", default=False,
+             action="store_true", dest="archived",
+             help="Include archived jobs in list (slow and expensive)")
+
 
 commands = {
   "list": (
     ListJobs, [ArgJobId()],
     [NOHDR_OPT, SEP_OPT, FIELDS_OPT, VERBOSE_OPT, FORCE_FILTER_OPT,
-     _PENDING_OPT, _RUNNING_OPT, _ERROR_OPT, _FINISHED_OPT],
+     _PENDING_OPT, _RUNNING_OPT, _ERROR_OPT, _FINISHED_OPT, _ARCHIVED_OPT],
     "[job_id ...]",
     "Lists the jobs and their status. The available fields can be shown"
     " using the \"list-fields\" command (see the man page for details)."
index 58adc18..56d3817 100644 (file)
@@ -81,6 +81,9 @@ fields will be added to the default list. This allows one to quickly
 see the default list plus a few other fields, instead of retyping
 the entire list of fields.
 
+To include archived jobs in the list the ``--archived`` option can be
+used.
+
 The following options can be used to show only specific jobs:
 
 ``--pending``