2 * Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
15 #include "../command.h"
16 #include <common/utils.h>
18 #ifdef LTTNG_EMBED_HELP
19 static const char *help_msg
=
20 #include <lttng-help.1.h>
24 static const char *lttng_help_msg
=
25 #ifdef LTTNG_EMBED_HELP
37 static struct poptOption long_options
[] = {
38 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
39 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
40 {"list-options", 0, POPT_ARG_NONE
, NULL
, OPT_LIST_OPTIONS
, NULL
, NULL
},
47 int cmd_help(int argc
, const char **argv
, const struct cmd_struct commands
[])
49 int opt
, ret
= CMD_SUCCESS
;
51 static poptContext pc
;
52 const struct cmd_struct
*cmd
;
54 const char *cmd_argv
[2];
56 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
57 poptReadDefaultConfig(pc
, 0);
59 while ((opt
= poptGetNextOpt(pc
)) != -1) {
64 case OPT_LIST_OPTIONS
:
65 list_cmd_options(stdout
, long_options
);
73 /* Get command name */
74 cmd_name
= (char *) poptGetArg(pc
);
76 if (cmd_name
== NULL
) {
77 /* Fall back to lttng(1) */
78 ret
= utils_show_help(1, "lttng", lttng_help_msg
);
80 ERR("Cannot show --help for `lttng`");
88 /* Help about help? */
89 if (strcmp(cmd_name
, "help") == 0) {
94 /* Make sure command name exists */
97 while (cmd
->name
!= NULL
) {
98 if (strcmp(cmd
->name
, cmd_name
) == 0) {
107 ERR("Unknown command \"%s\"", cmd_name
);
112 /* Show command's help */
113 cmd_argv
[0] = cmd
->name
;
114 cmd_argv
[1] = "--help";
116 ret
= cmd
->func(2, cmd_argv
);
This page took 0.031907 seconds and 4 git commands to generate.