mirror of
https://github.com/thepigeongenerator/cpusetcores.git
synced 2025-12-18 14:35:45 +01:00
add help option
This commit is contained in:
17
src/opts.c
17
src/opts.c
@@ -10,7 +10,7 @@ uint8_t getoptions(int32_t argc, char *const *argv, int32_t *ncpus) {
|
|||||||
uint8_t opts = 0;
|
uint8_t opts = 0;
|
||||||
char opt;
|
char opt;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "lavi")) != -1) {
|
while ((opt = getopt(argc, argv, "lavih")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'l':
|
case 'l':
|
||||||
if (opts & OPT_LIST_CORES) fatal("-%c has already been set", 'l');
|
if (opts & OPT_LIST_CORES) fatal("-%c has already been set", 'l');
|
||||||
@@ -29,7 +29,20 @@ uint8_t getoptions(int32_t argc, char *const *argv, int32_t *ncpus) {
|
|||||||
opts |= OPT_INVERT;
|
opts |= OPT_INVERT;
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
fatal("usage: %s [number] [-l] [-a] [-v] [-i]", argv[0]);
|
printf("specify -h for help\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
case 'h':
|
||||||
|
printf(
|
||||||
|
"%s: a tool for turning on/off CPU threads\n"
|
||||||
|
"USAGE: %s [integer] [-l] [-a] [-v] [-i] [-h]\n"
|
||||||
|
"ARGUMENTS:\n"
|
||||||
|
"\t-l : List cores after executing the command. May be specified without integer.\n"
|
||||||
|
"\t-a : Writes to all cores, regardless of their state.\n"
|
||||||
|
"\t-v : Print the cores that are written. (implies -l)\n"
|
||||||
|
"\t-i : Instead of the given number.\n"
|
||||||
|
"\t-h : Shows this dialogue.\n",
|
||||||
|
argv[0], argv[0]);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user