diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-07-26 23:09:02 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-07-26 23:32:03 +0200 |
commit | 0d7e32fa0a8e5f21a66c2f5504adabfa40523efc (patch) | |
tree | 9cf3a82ec74b93a71a6c1b77997aeefdf6e34c84 /src | |
parent | 11f96fac8f30423cb14f84622de9ed56b3b8f093 (diff) |
cgtop: add --version option
Diffstat (limited to 'src')
-rw-r--r-- | src/cgtop/cgtop.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index d8d36b3619..a57a468b2c 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -30,6 +30,7 @@ #include "util.h" #include "hashmap.h" #include "cgroup-util.h" +#include "build.h" typedef struct Group { char *path; @@ -511,6 +512,7 @@ static void help(void) { printf("%s [OPTIONS...]\n\n" "Show top control groups by their resource usage.\n\n" " -h --help Show this help\n" + " --version Print version and exit\n" " -p Order by path\n" " -t Order by number of tasks\n" " -c Order by CPU load\n" @@ -523,19 +525,25 @@ static void help(void) { program_invocation_short_name); } +static void version(void) { + puts(PACKAGE_STRING " cgtop"); +} + static int parse_argv(int argc, char *argv[]) { enum { - ARG_DEPTH = 0x100 + ARG_VERSION = 0x100, + ARG_DEPTH, }; static const struct option options[] = { - { "help", no_argument, NULL, 'h' }, - { "delay", required_argument, NULL, 'd' }, - { "iterations", required_argument, NULL, 'n' }, - { "batch", no_argument, NULL, 'b' }, - { "depth", required_argument, NULL, ARG_DEPTH }, - { NULL, 0, NULL, 0 } + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, ARG_VERSION }, + { "delay", required_argument, NULL, 'd' }, + { "iterations", required_argument, NULL, 'n' }, + { "batch", no_argument, NULL, 'b' }, + { "depth", required_argument, NULL, ARG_DEPTH }, + { NULL, 0, NULL, 0 } }; int c; @@ -552,6 +560,10 @@ static int parse_argv(int argc, char *argv[]) { help(); return 0; + case ARG_VERSION: + version(); + return 0; + case ARG_DEPTH: r = safe_atou(optarg, &arg_depth); if (r < 0) { |