1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
----------------- begin source -----------------------
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
GOptionContext *context = g_option_context_new(NULL);
g_option_context_set_summary(context, "Simple GLib commandline arguments parsing test.");
g_option_context_set_description(context, "This is a description. My name is psYchotic.");
gboolean test;
gchar *string;
gint integer;
GOptionEntry entries[] = {
{ "test", 't', 0, G_OPTION_ARG_NONE, &test, "bla", NULL },
{ "string", '0', 0, G_OPTION_ARG_STRING, &string, "bla", "name" },
{ "integer", 'i', 0, G_OPTION_ARG_INT, &integer, "bla", "int" }
};
g_option_context_add_main_entries(context, entries, NULL);
g_option_context_parse(context, &argc, &argv, NULL);
return 0;
}
----------------- end source -------------------------
----------------- begin output -----------------------
[Invalid UTF-8] Usage:
test [OPTION...]
Simple GLib commandline arguments parsing test.
Help Options:
-?, --help Show help options
Application Options:
-t, --test bla
-0, --string=name bla
-i, --integer=int bla
--L\x89d$\xe0L\x89l$\xe8I\x89\xd5L\x89t$\xf0L\x89|$\xf8I\x89\xf6H\x89\$\xd0H\x89l$\xd8H\x83\xec8A\x89\xff\xe8H\xfd\xff\xffH\x8d\x05\x9d\x05 =\x89\xc7\xe8eU\x01
This is a description. My name is psYchotic.
------------------- end output -----------------------
|