--help argument -h added to main and option.c
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 10 Sep 2003 19:54:47 +0000 (19:54 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 10 Sep 2003 19:54:47 +0000 (19:54 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@228 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/Makefile.am
ltt/branches/poly/lttv/main.c
ltt/branches/poly/lttv/option.c

index b89688e8255d2bc3cf618d290b13f2df706c1e32..8364876199bbefeb52f37dec63a892655fbf4806 100644 (file)
@@ -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
+
index a1bfcd087726a8f6349d3f4240fea13b0ac3ea7a..7da2a99d46452f7e614875b51ece887249b166ef 100644 (file)
@@ -7,6 +7,8 @@
 #include <lttv/option.h>
 #include <lttv/traceset.h>
 #include <ltt/trace.h>
+#include <stdio.h>
+
 
 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");
+}
index 4c45d2ab97d21cbd19ab1b0c13ca63750cc3d78b..01237acb2e62b67446c8b8ecb582d456c9b8fd7f 100644 (file)
@@ -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);
+
+
+}
This page took 0.025474 seconds and 4 git commands to generate.