diff --git a/src/opts.c b/src/opts.c index 1d44c69..e32e44d 100644 --- a/src/opts.c +++ b/src/opts.c @@ -10,7 +10,7 @@ uint8_t getoptions(int32_t argc, char *const *argv, int32_t *ncpus) { uint8_t opts = 0; char opt; - while ((opt = getopt(argc, argv, "lavi")) != -1) { + while ((opt = getopt(argc, argv, "lavih")) != -1) { switch (opt) { case '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; break; 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); } }