CNDP  22.08.0
cli_help.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/queue.h>
#include "cli_map.h"
#include "cne_common.h"

Go to the source code of this file.

Functions

CNDP_API struct help_node * cli_help_find_group (const char *group)
 
CNDP_API int cli_help_show_all (const char *msg)
 
CNDP_API int cli_help_show_group (const char *group)
 
CNDP_API int cli_help_add (const char *group, struct cli_map *map, const char **hd)
 
static int is_help (int argc, char **argv)
 
CNDP_API void cli_help_foreach (void(*func)(void *arg, const char **h), void *arg)
 
CNDP_API int cli_cmd_error (const char *msg, const char *group, int argc, char **argv)
 

Detailed Description

CNE Command line interface

Definition in file cli_help.h.

Function Documentation

◆ cli_help_find_group()

CNDP_API struct help_node* cli_help_find_group ( const char *  group)

Find the help group section defined by the group string.

Note
Uses thread variable this_cli.
Parameters
groupThe group string name to find.
Returns
NULL if not found or pointer to struct cli_info.

◆ cli_help_show_all()

CNDP_API int cli_help_show_all ( const char *  msg)

Show the map table entries

Parameters
msgPointer to a message to print first.
Returns
0 on success or -1 on error

◆ cli_help_show_group()

CNDP_API int cli_help_show_group ( const char *  group)

Show the help message for the user.

Note
Uses thread variable this_cli.
Parameters
groupPointer to the cli_info structure.

◆ cli_help_add()

CNDP_API int cli_help_add ( const char *  group,
struct cli_map *  map,
const char **  hd 
)

Add help string group to a help structure

Parameters
groupThe group name for this help list
mapThe pointer to the MAP structure if present.
hdThe array of string pointers for the help group
Returns
0 on OK and -1 on error

◆ is_help()

static int is_help ( int  argc,
char **  argv 
)
inlinestatic

Find if the last item is a help request.

Parameters
argcNumber of args in the argv list.
argvList of strings to parser
Returns
1 if true or 0 if false

Definition at line 100 of file cli_help.h.

◆ cli_help_foreach()

CNDP_API void cli_help_foreach ( void(*)(void *arg, const char **h)  func,
void *  arg 
)

Iterate over the help messages calling a given function.

Parameters
funcA function to call for all help lines.
argArgument pointer for function call.
Returns
N/A

◆ cli_cmd_error()

CNDP_API int cli_cmd_error ( const char *  msg,
const char *  group,
int  argc,
char **  argv 
)

Process a CLI command error

Parameters
msgThe message to display on error
groupThe group string for this command
argcNumber or arguments in the argv array
argvThe array of string pointers for the command line.
Returns
0 on success or -1 on error