From: compudj Date: Wed, 10 Sep 2003 19:54:47 +0000 (+0000) Subject: --help argument -h added to main and option.c X-Git-Tag: v0.12.20~3261 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d888c9c8f4c3e7b4e1516fca135b5be62f7aeea3;p=lttv.git --help argument -h added to main and option.c git-svn-id: http://ltt.polymtl.ca/svn@228 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/Makefile.am b/ltt/branches/poly/lttv/Makefile.am index b89688e8..83648761 100644 --- a/ltt/branches/poly/lttv/Makefile.am +++ b/ltt/branches/poly/lttv/Makefile.am @@ -1,5 +1,3 @@ -SUBDIRS = modules - AM_CFLAGS = $(GLIB_CFLAGS) LIBS += $(GLIB_LIBS) -lgobject-2.0 -L$(top_srcdir)/ltt -ltraceread #LIBS += $(GLIB_LIBS) -lgobject-2.0 -lltt @@ -31,3 +29,9 @@ libtextDump_la_LDFLAGS = -module libtextDump_la_SOURCES = textDump.c libbatchAnalysis_la_LDFLAGS = -module libbatchAnalysis_la_SOURCES = batchAnalysis.c + + +# WARNING : must be done at the end, so modules can dynamically link themselves +# to libraries compiled here but not installed in the system. +SUBDIRS = modules + diff --git a/ltt/branches/poly/lttv/main.c b/ltt/branches/poly/lttv/main.c index a1bfcd08..7da2a99d 100644 --- a/ltt/branches/poly/lttv/main.c +++ b/ltt/branches/poly/lttv/main.c @@ -7,6 +7,8 @@ #include #include #include +#include + void lttv_option_init(int argc, char **argv); void lttv_option_destroy(); @@ -41,6 +43,7 @@ static void lttv_module_option(void *hook_data); static void lttv_module_path_option(void *hook_data); +static void lttv_help(void); /* Since everything is done in modules, the main program only takes care of the infrastructure. */ @@ -98,7 +101,11 @@ int main(int argc, char **argv) { "add a directory to the module search path", "directory to add to the path", LTTV_OPT_STRING, &a_module_path, lttv_module_path_option, NULL); - + + lttv_option_add("help",'h', "basic help", "none", + LTTV_OPT_NONE, NULL, lttv_help, NULL); + + lttv_hooks_call(before_options, NULL); lttv_option_parse(argc, argv); lttv_hooks_call(after_options, NULL); @@ -139,3 +146,11 @@ void lttv_module_path_option(void *hook_data) { lttv_module_path_add(a_module_path); } + +void lttv_help() +{ + printf("Linux Trace Toolkit Visualizer\n"); + printf("\n"); + lttv_option_show_help(); + printf("\n"); +} diff --git a/ltt/branches/poly/lttv/option.c b/ltt/branches/poly/lttv/option.c index 4c45d2ab..01237acb 100644 --- a/ltt/branches/poly/lttv/option.c +++ b/ltt/branches/poly/lttv/option.c @@ -215,3 +215,32 @@ void lttv_option_parse(int argc, char **argv) destroy_popts(&list, &popts, &c); } +static void show_help(LttvOption *option) +{ + printf("--%s -%c argument: %s\n" , option->long_name, + option->char_name, + option->arg_description); + printf(" %s\n" , option->description); + +} + +void lttv_option_show_help(void) +{ + LttvOption option; + + GPtrArray *list = g_ptr_array_new(); + + int i; + + g_hash_table_foreach(options, list_options, list); + + printf("Built-in commands available:\n"); + printf("\n"); + + for(i = 0 ; i < list->len ; i++) { + show_help((LttvOption *)list->pdata[i]); + } + g_ptr_array_free(list, TRUE); + + +}