]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgtop: add "-1" as shortcut for "--iterations=1"
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2018 15:56:12 +0000 (16:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2018 15:58:01 +0000 (16:58 +0100)
This is most likely the most useful use of --iterations, and such use
for numeric parameters has precedents, let's make this work for cgtop too.

man/systemd-cgtop.xml
src/cgtop/cgtop.c

index d7ad08ec373cfd6b4013f4f2c7954889c83df2aa..295f2351961c00e24d00c4f497933597197b612e 100644 (file)
         indefinitely.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>-1</option></term>
+
+        <listitem><para>A shortcut for <option>--iterations=1</option>.</para></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>-d</option></term>
         <term><option>--delay=</option></term>
index c68b56568ba5c1b39b67694457f826da8bdd94ba..1575cd51ff4d9e1a9773bd411270b77e1503bb33 100644 (file)
@@ -713,6 +713,7 @@ static void help(void) {
                "     --recursive=BOOL Sum up process count recursively\n"
                "  -d --delay=DELAY    Delay between updates\n"
                "  -n --iterations=N   Run for N iterations before exiting\n"
+               "  -1                  Shortcut for --iterations=1\n"
                "  -b --batch          Run in batch mode, accepting no input\n"
                "     --depth=DEPTH    Maximum traversal depth (default: %u)\n"
                "  -M --machine=       Show container\n"
@@ -749,7 +750,7 @@ static int parse_argv(int argc, char *argv[]) {
         assert(argc >= 1);
         assert(argv);
 
-        while ((c = getopt_long(argc, argv, "hptcmin:brd:kPM:", options, NULL)) >= 0)
+        while ((c = getopt_long(argc, argv, "hptcmin:brd:kPM:1", options, NULL)) >= 0)
 
                 switch (c) {
 
@@ -802,6 +803,10 @@ static int parse_argv(int argc, char *argv[]) {
 
                         break;
 
+                case '1':
+                        arg_iterations = 1;
+                        break;
+
                 case 'b':
                         arg_batch = true;
                         break;