X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fhelp.c;h=a9a01e7f14a65db8084e5b8cdbdaa6c0ad038c8d;hb=a0377dfefe40662ba7d68617bce6ff467114136c;hp=29f56bab1778f3dd38ce5186bc5da6a21b7ebc7e;hpb=960afba4f737174cd305af2019d9c2c781ec6c4e;p=lttng-tools.git diff --git a/src/bin/lttng/commands/help.c b/src/bin/lttng/commands/help.c index 29f56bab1..a9a01e7f1 100644 --- a/src/bin/lttng/commands/help.c +++ b/src/bin/lttng/commands/help.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2015 - Philippe Proulx + * Copyright (C) 2015 Philippe Proulx * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -24,6 +14,20 @@ #include "../command.h" #include +#ifdef LTTNG_EMBED_HELP +static const char *help_msg = +#include +; +#endif + +static const char *lttng_help_msg = +#ifdef LTTNG_EMBED_HELP +#include +#else +NULL +#endif +; + enum { OPT_HELP = 1, OPT_LIST_OPTIONS, @@ -46,6 +50,7 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) 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); @@ -69,14 +74,20 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) 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 */ @@ -97,14 +108,11 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) 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"; + LTTNG_ASSERT(cmd->func); + ret = cmd->func(2, cmd_argv); end: poptFreeContext(pc);