mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
cgtop: add --version option
This commit is contained in:
parent
11f96fac8f
commit
0d7e32fa0a
@ -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,14 +525,20 @@ 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' },
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "delay", required_argument, NULL, 'd' },
|
||||
{ "iterations", required_argument, NULL, 'n' },
|
||||
{ "batch", no_argument, NULL, 'b' },
|
||||
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user