Openbox-esque help

This commit is contained in:
Keith Bowes 2020-03-09 21:20:04 -04:00
parent 81887c631c
commit 7bb4e79256

View file

@ -1,24 +1,38 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <wayland-server.h>
#include "waybox/server.h"
bool show_help(char *name)
{
printf(_("Syntax: %s [options]\n"), name);
printf(_("\nOptions:\n"));
printf(_(" --help Display this help and exit\n"));
printf(_(" --version Display the version and exit\n"));
/* TRANSLATORS: If you translate FILE, be sure the text remains aligned. */
printf(_(" --config-file FILE Specify the path to the config file to use\n"));
printf(_(" --sm-disable Disable connection to the session manager\n"));
printf(_(" --startup CMD Run CMD after starting\n"));
printf(_(" --debug Display debugging output\n"));
printf(_("\nOther Openbox options aren't accepted, "
"mostly due to them being nonsensical on Wayland.\n"));
return true;
}
int main(int argc, char **argv) {
textdomain(GETTEXT_PACKAGE);
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
setlocale(LC_ALL, NULL);
textdomain(GETTEXT_PACKAGE);
char *startup_cmd = NULL;
bool debug = false;
if (argc > 0) {
if (argc > 1) {
int i;
for (i = 0; i < argc; i++) {
if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i])) {
debug = true;
} else if (!strcmp("--exit", argv[i])) {
fprintf(stderr, _("Warning: option %s is currently unimplemented\n"), argv[i]);
} else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i]))) {
if (i < argc - 1) {
startup_cmd = argv[i + 1];
@ -28,9 +42,18 @@ int main(int argc, char **argv) {
} else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
return 0;
} else if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
show_help(argv[0]);
return 0;
} else if (!strcmp("--config-file", argv[i]) ||
!strcmp("--sm-disable", argv[i])) {
fprintf(stderr, _("Warning: option '%s' hasn't been implemented yet.\n"), argv[i]);
if (i == argc - 1) {
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
}
} else if (argv[i][0] == '-') {
printf(_("Usage: %s [--debug] [--exit] [--help] [--startup CMD] [--version]\n"), argv[0]);
return strcmp("--help", argv[i]) != 0 && strcmp("-h", argv[i]) != 0;
show_help(argv[0]);
return 1;
}
}
}