]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
add the long options to cgget
authorIvana Hutarova Varekova <varekova@redhat.com>
Thu, 2 Sep 2010 10:17:41 +0000 (12:17 +0200)
committerJan Safranek <jsafrane@redhat.com>
Fri, 17 Sep 2010 08:08:01 +0000 (10:08 +0200)
This patch adds the long options parsing to cgget
to be consistent with the other tools

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
doc/man/cgget.1
src/tools/cgget.c

index 543f7f2f41806e2e8055b503d50e752a4474adc5..c8d3048dc272198ca50fd9ff15b214aeda1ccbdd 100644 (file)
@@ -21,7 +21,7 @@ is the name of the cgroup which should be read.
 This parameter can be used multiple times.
 
 .TP
-.B -r <name>
+.B -r, --variable <name>
 defines parameter to display.
 This option can be used multiple times.
 
@@ -31,7 +31,7 @@ defines controller which values should be displaied.
 This option can be used multiple times.
 
 .TP
-.B -a
+.B -a, --all
 print the variables for all controllers which consists given cgroup
 
 .TP
@@ -39,9 +39,13 @@ print the variables for all controllers which consists given cgroup
 do not print headers, i.e. name of groups.
 
 .TP
-.B -v
+.B -v, --values-only
 print only values, not parameter names.
 
+.TP
+.B -h, --help
+display help and exit
+
 .SH EXAMPLES
 .nf
 $ cgget -r cpuset.cpus -r cpuset.mems first second
index 71381e119e6b6a4c9bc324319621d8511d94cdcb..f63a98bbb8698bd404c21116aa7a5119dc0358a1 100644 (file)
 
 #define LL_MAX                         100
 
+static struct option const long_options[] =
+{
+       {"variable", required_argument, NULL, 'r'},
+       {"help", no_argument, NULL, 'h'},
+       {"all",  no_argument, NULL, 'a'},
+       {"values-only", no_argument, NULL, 'v'},
+       {NULL, 0, NULL, 0}
+};
+
+
 static void usage(int status, const char *program_name)
 {
        if (status != 0)
@@ -22,7 +32,7 @@ static void usage(int status, const char *program_name)
                        " try %s -h' for more information.\n",
                        program_name);
        else {
-               printf("Usage: %s [-nv] [-r<name>] [-g<controller>] [-a] ..."\
+               printf("Usage: %s [-nv] [-r<name>] [-g<controller>] [-a] ... "\
                        "<path> ...\n", program_name);
        }
 }
@@ -279,7 +289,8 @@ int main(int argc, char *argv[])
        }
 
        /* Parse arguments. */
-       while ((c = getopt(argc, argv, "r:hnvg:a")) != -1) {
+       while ((c = getopt_long(argc, argv, "r:hnvg:a", long_options, NULL))
+               > 0) {
                switch (c) {
                case 'h':
                        usage(0, argv[0]);