#include "util.h"
#include "hashmap.h"
#include "cgroup-util.h"
+#include "build.h"
typedef struct Group {
char *path;
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"
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;
help();
return 0;
+ case ARG_VERSION:
+ version();
+ return 0;
+
case ARG_DEPTH:
r = safe_atou(optarg, &arg_depth);
if (r < 0) {