about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-07-20 00:39:21 +0100
committerJames Booth <boothj5@gmail.com>2012-07-20 00:39:21 +0100
commit7c908780622319671337986186cda1428b9e0272 (patch)
tree51136a90815575b485cdffe00659f0ca3d79e46f
parent696848bdc3299e62b883ff71fea8f962f74e2153 (diff)
downloadprofani-tty-7c908780622319671337986186cda1428b9e0272.tar.gz
Command line args and welcome message
-rw-r--r--src/main.c42
-rw-r--r--src/windows.c16
2 files changed, 44 insertions, 14 deletions
diff --git a/src/main.c b/src/main.c
index 520fb4bb..8bd5df56 100644
--- a/src/main.c
+++ b/src/main.c
@@ -19,30 +19,46 @@
  * along with Profanity.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
+#include <config.h>
 
 #include <stdio.h>
 #include <string.h>
 
+#include <glib.h>
+
 #include "profanity.h"
 
+static gboolean disable_tls = FALSE;
+static gboolean version = FALSE;
+
 int main(int argc, char **argv)
 {   
-    int disable_tls = 0;
+    static GOptionEntry entries[] = 
+    {
+        { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL },
+        { "disable-tls", 'd', 0, G_OPTION_ARG_NONE, &disable_tls, "Disable TLS", NULL },
+        { NULL }
+    };
+  
+    GError *error = NULL;
+    GOptionContext *context;
 
-    // more than one argument
-    if (argc > 2) {
-        printf("Usage: profanity [-notls]\n");
+    context = g_option_context_new(NULL);
+    g_option_context_add_main_entries(context, entries, NULL);
+    //g_option_context_add_group(context, gtk_get_option_group (TRUE));
+    if (!g_option_context_parse(context, &argc, &argv, &error)) {
+        g_print("%s\n", error->message);
         return 1;
+    }
 
-    // argument is not -notls
-    } else if (argc == 2) {
-        char *arg1 = argv[1];
-        if (strcmp(arg1, "-notls") != 0) {
-            printf("Usage: profanity [-notls]\n");
-            return 1;
-        } else {
-            disable_tls = 1;
-        }
+    if (version == TRUE) {
+        g_print("Profanity, version %s\n", PACKAGE_VERSION);
+        g_print("Copyright (C) 2012 James Booth <%s>.\n", PACKAGE_BUGREPORT);
+        g_print("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
+        g_print("\n");
+        g_print("This is free software; you are free to change and redistribute it.\n");
+        g_print("There is NO WARRANTY, to the extent permitted by law.\n");
+        return 0;
     }
 
     profanity_init(disable_tls);
diff --git a/src/windows.c b/src/windows.c
index 5a0b12d7..b5378069 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -474,7 +474,21 @@ static void _create_windows(void)
     if (prefs_get_showsplash()) {
         _print_splash_logo(_cons_win);
     } else {
-        wprintw(_cons_win, "Welcome to Profanity.\n");
+        wprintw(_cons_win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION);
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "Copyright (C) 2012 James Booth <%s>.\n", PACKAGE_BUGREPORT);
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "\n");
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "This is free software; you are free to change and redistribute it.\n");
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "There is NO WARRANTY, to the extent permitted by law.\n");
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "\n");
+        _win_show_time(_cons_win);
+        wprintw(_cons_win, "Type '/help' to get started.\n");
     }
     prefresh(_cons_win, 0, 0, 1, 0, rows-3, cols-1);