From a4b48c1342782a5a09ad0d42f713c361def94061 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 30 May 2007 01:23:06 +0000 Subject: [PATCH] add --help and --version. without any args and a .obt, it will be installed --- src/main.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index a9c8e1c..7afa615 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,7 @@ #define SN_API_NOT_YET_FROZEN #include #undef SN_API_NOT_YET_FROZEN +#include GtkWidget *mainwin = NULL; @@ -51,12 +52,43 @@ void obconf_error(gchar *msg) gtk_widget_show(d); } +static void print_version() +{ + g_print("ObConf %s\n", PACKAGE_VERSION); + g_print(_("Copyright (c)")); + g_print(" 2003-2007 Dana Jansens\n"); + g_print(_("Copyright (c)")); + g_print(" 2003 Tim Riley\n\n"); + g_print("This program comes with ABSOLUTELY NO WARRANTY.\n"); + g_print("This is free software, and you are welcome to redistribute it\n"); + g_print("under certain conditions. See the file COPYING for details.\n\n"); + + exit(EXIT_SUCCESS); +} + +static void print_help() +{ + g_print(_("Syntax: obconf [options] [ARCHIVE.obt]\n")); + g_print(_("\nOptions:\n")); + g_print(_(" --help Display this help and exit\n")); + g_print(_(" --version Display the version and exit\n")); + g_print(_(" --install ARCHIVE.obt Install the given theme archive and select it\n")); + g_print(_(" --archive THEME Create a theme archive from the given theme directory\n")); + g_print(_("\nPlease report bugs at %s\n\n"), PACKAGE_BUGREPORT); + + exit(EXIT_SUCCESS); +} + static void parse_args(int argc, char **argv) { int i; for (i = 1; i < argc; ++i) { - if (!strcmp(argv[i], "--install")) { + if (!strcmp(argv[i], "--help")) + print_help(); + if (!strcmp(argv[i], "--version")) + print_version(); + else if (!strcmp(argv[i], "--install")) { if (i == argc - 1) /* no args left */ g_printerr(_("--install requires an argument\n")); else @@ -67,7 +99,8 @@ static void parse_args(int argc, char **argv) g_printerr(_("--archive requires an argument\n")); else obc_theme_archive = argv[++i]; - } + } else + obc_theme_install = argv[i]; } } -- 2.39.2