CNDP  22.08.0
cli_help.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2019-2022 Intel Corporation.
3  */
4 
5 #ifndef _CLI_HELP_H_
6 #define _CLI_HELP_H_
7 
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11 #include <string.h> // for strcmp
12 #include <stdarg.h>
13 #include <unistd.h>
14 #include <inttypes.h>
15 #include <sys/queue.h> // for TAILQ_ENTRY
16 
17 #include "cli_map.h" // for cli_map
18 #include "cne_common.h" // for CNDP_API
19 
20 // IWYU pragma: no_forward_declare cli_map
21 struct cli_map;
22 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define CLI_HELP_PAUSE "<<PauseOutput>>"
34 #define CLI_HELP_NAME_LEN 32
35 
36 struct help_node {
37  TAILQ_ENTRY(help_node) next;
38  char group[CLI_HELP_NAME_LEN];
39  struct cli_map *map;
40  const char **help_data;
41 };
42 
53 CNDP_API struct help_node *cli_help_find_group(const char *group);
54 
63 CNDP_API int cli_help_show_all(const char *msg);
64 
73 CNDP_API int cli_help_show_group(const char *group);
74 
87 CNDP_API int cli_help_add(const char *group, struct cli_map *map, const char **hd);
88 
99 static inline int
100 is_help(int argc, char **argv)
101 {
102  if (argc == 0)
103  return 0;
104 
105  return !strcmp("-?", argv[argc - 1]) || !strcmp("?", argv[argc - 1]);
106 }
107 
118 CNDP_API void cli_help_foreach(void (*func)(void *arg, const char **h), void *arg);
119 
134 CNDP_API int cli_cmd_error(const char *msg, const char *group, int argc, char **argv);
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif /* _CLI_HELP_H_ */
CNDP_API int cli_help_show_group(const char *group)
CNDP_API int cli_help_show_all(const char *msg)
CNDP_API void cli_help_foreach(void(*func)(void *arg, const char **h), void *arg)
static int is_help(int argc, char **argv)
Definition: cli_help.h:100
CNDP_API struct help_node * cli_help_find_group(const char *group)
CNDP_API int cli_cmd_error(const char *msg, const char *group, int argc, char **argv)
CNDP_API int cli_help_add(const char *group, struct cli_map *map, const char **hd)