mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-08-05 20:58:29 +02:00
Add -h and -v and augment the usage text with option descriptions
This commit is contained in:
@@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
#include "daemonize.h"
|
||||
#include "dbus_messaging.h"
|
||||
#include "gamemode.h"
|
||||
@@ -58,6 +59,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define USAGE_TEXT \
|
||||
"Usage: %s [-d] [-l] [-h] [-v]\n\n" \
|
||||
" -d daemonize self after launch\n" \
|
||||
" -l log to syslog\n" \
|
||||
" -h print this help\n" \
|
||||
" -v print version\n" \
|
||||
"\n" \
|
||||
"See man page for more information.\n"
|
||||
|
||||
#define VERSION_TEXT "gamemode version: v" GAMEMODE_VERSION "\n"
|
||||
|
||||
static void sigint_handler(__attribute__((unused)) int signo)
|
||||
{
|
||||
LOG_MSG("Quitting by request...\n");
|
||||
@@ -79,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
bool daemon = false;
|
||||
bool use_syslog = false;
|
||||
int opt = 0;
|
||||
while ((opt = getopt(argc, argv, "dl")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "dlvh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
daemon = true;
|
||||
@@ -87,8 +99,16 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
use_syslog = true;
|
||||
break;
|
||||
case 'v':
|
||||
fprintf(stdout, VERSION_TEXT);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'h':
|
||||
fprintf(stdout, USAGE_TEXT, argv[0]);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s [-d] [-l]\n", argv[0]);
|
||||
fprintf(stderr, USAGE_TEXT, argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user