commit:     966de456d8af3b5102950e608a771f776efdd014
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 13 13:37:31 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 13 13:37:31 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=966de456

qlop: support -q to omit timestamps

Allow -q to suppress timestamps and operation markers (<<<, >>> and ***)
such that one can generate a flat list of atoms. A bit awkward, but
combining -q *and* -v will result in atoms with PF (iso PN).

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md                       |  5 -----
 man/include/qlop.optdesc.yaml |  4 ++++
 man/qlop.1                    |  2 +-
 qlop.c                        | 24 +++++++++++++++++++++---
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/TODO.md b/TODO.md
index f410f54..ccff6e0 100644
--- a/TODO.md
+++ b/TODO.md
@@ -75,11 +75,6 @@
 
 - make it use standard xarray instead of its own buf\_list
 
-# qlop
-
-- have a mode that doesn't print timestamp (to get just atoms, -v should
-  work)
-
 # qlist
 - have -F for use with -I so one can do things like print SLOT for
   package X

diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml
index 677c4d2..19f56db 100644
--- a/man/include/qlop.optdesc.yaml
+++ b/man/include/qlop.optdesc.yaml
@@ -42,6 +42,10 @@ current: |
     in order to detect running merges.
 verbose: |
     Print package versions and revisions (PF) instead of package (PN).
+quiet:
+    Omit printing of timestamps and operation symbols, can be used to
+    generate a flat list of atoms, e.g.\ \fB-qml\fR to print the package
+    names merged in the last emerge operation.
 running: |
     Print operations currently in progress.  An ETA is calculated based
     on the average for the operation.  If the elapsed exceeds the

diff --git a/man/qlop.1 b/man/qlop.1
index ae40fa7..6303eee 100644
--- a/man/qlop.1
+++ b/man/qlop.1
@@ -116,7 +116,7 @@ Set the ROOT env var.
 Print package versions and revisions (PF) instead of package (PN).
 .TP
 \fB\-q\fR, \fB\-\-quiet\fR
-Tighter output; suppress warnings.
+Omit printing of timestamps and operation symbols, can be used to generate a 
flat list of atoms, e.g.\ \fB-qml\fR to print the package names merged in the 
last emerge operation.
 .TP
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.

diff --git a/qlop.c b/qlop.c
index 5217638..11bbbc3 100644
--- a/qlop.c
+++ b/qlop.c
@@ -506,7 +506,13 @@ static int do_emerge_log(
                                        sync_start = 0;  /* reset */
                                        continue;
                                }
-                               if (flags->do_time) {
+                               if (quiet) {
+                                       printf("%s%s%s%s%s\n",
+                                                       GREEN, p, NORM,
+                                                       flags->do_time ? ": " : 
"",
+                                                       flags->do_time ?
+                                                               
fmt_elapsedtime(flags, elapsed) : "");
+                               } else if (flags->do_time) {
                                        printf("%s *** %s%s%s: %s\n",
                                                        fmt_date(flags, 
sync_start, tstart),
                                                        GREEN, p, NORM,
@@ -607,7 +613,13 @@ static int do_emerge_log(
                                                }
                                                break;
                                        }
-                                       if (flags->do_time) {
+                                       if (quiet && !flags->do_average) {
+                                               printf("%s%s%s\n",
+                                                               
atom_format(afmt, pkgw->atom, 0),
+                                                               flags->do_time 
? ": " : "",
+                                                               flags->do_time ?
+                                                                       
fmt_elapsedtime(flags, elapsed) : "");
+                                       } else if (flags->do_time) {
                                                printf("%s >>> %s: %s\n",
                                                                fmt_date(flags, 
pkgw->tbegin, tstart),
                                                                
atom_format(afmt, pkgw->atom, 0),
@@ -706,7 +718,13 @@ static int do_emerge_log(
                                                }
                                                break;
                                        }
-                                       if (flags->do_time) {
+                                       if (quiet && !flags->do_average) {
+                                               printf("%s%s%s\n",
+                                                               
atom_format(afmt, pkgw->atom, 0),
+                                                               flags->do_time 
? ": " : "",
+                                                               flags->do_time ?
+                                                                       
fmt_elapsedtime(flags, elapsed) : "");
+                                       } else if (flags->do_time) {
                                                printf("%s <<< %s: %s\n",
                                                                fmt_date(flags, 
pkgw->tbegin, tstart),
                                                                
atom_format(afmt, pkgw->atom, 0),

Reply via email to