This patch adds the long options parsing to cgget
to be consistent with the other tools

Signed-off-by: Ivana Hutarova Varekova <[email protected]>
---

 doc/man/cgget.1   |   10 +++++++---
 src/tools/cgget.c |   15 +++++++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/doc/man/cgget.1 b/doc/man/cgget.1
index 543f7f2..c8d3048 100644
--- a/doc/man/cgget.1
+++ b/doc/man/cgget.1
@@ -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
diff --git a/src/tools/cgget.c b/src/tools/cgget.c
index 2cc4d7c..9899df6 100644
--- a/src/tools/cgget.c
+++ b/src/tools/cgget.c
@@ -15,6 +15,16 @@
 
 #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);
        }
 }
@@ -257,7 +267,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]);


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to