2 * Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
14 #include "../command.h"
15 #include <common/utils.h>
17 #ifdef LTTNG_EMBED_HELP
18 static const char *help_msg
=
19 #include <lttng-help.1.h>
23 static const char *lttng_help_msg
=
24 #ifdef LTTNG_EMBED_HELP
36 static struct poptOption long_options
[] = {
37 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
38 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
39 {"list-options", 0, POPT_ARG_NONE
, NULL
, OPT_LIST_OPTIONS
, NULL
, NULL
},
46 int cmd_help(int argc
, const char **argv
, const struct cmd_struct commands
[])
48 int opt
, ret
= CMD_SUCCESS
;
50 static poptContext pc
;
51 const struct cmd_struct
*cmd
;
53 const char *cmd_argv
[2];
55 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
56 poptReadDefaultConfig(pc
, 0);
58 while ((opt
= poptGetNextOpt(pc
)) != -1) {
63 case OPT_LIST_OPTIONS
:
64 list_cmd_options(stdout
, long_options
);
72 /* Get command name */
73 cmd_name
= (char *) poptGetArg(pc
);
75 if (cmd_name
== NULL
) {
76 /* Fall back to lttng(1) */
77 ret
= utils_show_help(1, "lttng", lttng_help_msg
);
79 ERR("Cannot show --help for `lttng`");
87 /* Help about help? */
88 if (strcmp(cmd_name
, "help") == 0) {
93 /* Make sure command name exists */
96 while (cmd
->name
!= NULL
) {
97 if (strcmp(cmd
->name
, cmd_name
) == 0) {
106 ERR("Unknown command \"%s\"", cmd_name
);
111 /* Show command's help */
112 cmd_argv
[0] = cmd
->name
;
113 cmd_argv
[1] = "--help";
114 LTTNG_ASSERT(cmd
->func
);
115 ret
= cmd
->func(2, cmd_argv
);
This page took 0.032125 seconds and 4 git commands to generate.