#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "../command.h"
#include <common/utils.h>
+#ifdef LTTNG_EMBED_HELP
+static const char *help_msg =
+#include <lttng-help.1.h>
+;
+#endif
+
+static const char *lttng_help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng.1.h>
+#else
+NULL
+#endif
+;
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static poptContext pc;
const struct cmd_struct *cmd;
int found = 0;
+ const char *cmd_argv[2];
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
if (cmd_name == NULL) {
/* Fall back to lttng(1) */
- ret = utils_show_man_page(1, "lttng");
-
+ ret = utils_show_help(1, "lttng", lttng_help_msg);
if (ret) {
- ERR("Cannot view man page lttng(1)");
+ ERR("Cannot show --help for `lttng`");
perror("exec");
ret = CMD_ERROR;
- goto end;
}
+
+ goto end;
+ }
+
+ /* Help about help? */
+ if (strcmp(cmd_name, "help") == 0) {
+ SHOW_HELP();
+ goto end;
}
/* Make sure command name exists */
goto end;
}
- /* Show command's man page */
- ret = show_cmd_man_page(cmd_name);
-
- if (ret) {
- ERR("Cannot view man page lttng-%s(1)", cmd_name);
- perror("exec");
- ret = CMD_ERROR;
- }
+ /* Show command's help */
+ cmd_argv[0] = cmd->name;
+ cmd_argv[1] = "--help";
+ assert(cmd->func);
+ ret = cmd->func(2, cmd_argv);
end:
poptFreeContext(pc);