Skip to content

Commit adc9a2d

Browse files
committed
bug fix and help msg add
1 parent f2c41a4 commit adc9a2d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Introduce
88
This is used to handle command line input.
99
Programers can write a struct to describe the input and accord function,
1010
Despite the getopt process and error handler
11+
eg:
12+
make
13+
./objcli node set --meta=hank
14+
./objcli node get --meta=hank
1115

1216
Usage
1317
--------

obj_cli.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/** MAX OPTION */
1515
#define CLI_MAX_OPTION 255
1616
/** MAX TYPE */
17-
#define CLI_MAX_OBJECT 255
17+
#define CLI_MAX_OBJECRequest 255
1818
/** MAX ACTION */
1919
#define CLI_MAX_ACTION 255
2020
/** declare request variable */
@@ -58,7 +58,7 @@ template <class Request, class Context>
5858
struct CliAction
5959
{
6060
/** function */
61-
typedef int (*CliAction_imp)(T& request, Context *context);
61+
typedef int (*CliAction_imp)(Request& request, Context *context);
6262

6363
/** action name */
6464
const char* action;
@@ -213,7 +213,7 @@ void print_usage(InvokeContext<Request,Context> &env, bool completion)
213213
* @brief invoke with request
214214
*/
215215
template <class Request, class Context>
216-
int CliInvoke(T &request, Context *context, InvokeContext<Request,Context> &env)
216+
int CliInvoke(Request &request, Context *context, InvokeContext<Request,Context> &env)
217217
{
218218
return (env.meta[env.object_index].actions[env.action_index].handler) (request, context);
219219
}
@@ -226,7 +226,7 @@ bool is_completion(int argc, char *argv[]);
226226
* @brief parse options
227227
*/
228228
template <class Request, class Context>
229-
int CliParse(int argc, char *argv[], T &request, InvokeContext<Request,Context> &env)
229+
int CliParse(int argc, char *argv[], Request &request, InvokeContext<Request,Context> &env)
230230
{
231231
int missing_index = -1;
232232
int option_index = 0;
@@ -371,7 +371,7 @@ int CliParse(int argc, char *argv[], T &request, InvokeContext<Request,Context>
371371
template <class Request, class Context>
372372
int CliInvoke(int argc, char *argv[], Context *context, InvokeContext<Request,Context> &env)
373373
{
374-
T request;
374+
Request request;
375375
int ret = CliParse(argc, argv, request, env);
376376
if(0 != ret){
377377
return ret;
@@ -389,7 +389,7 @@ int CliInvoke(int argc, char *argv[],
389389
{
390390
InvokeContext<Request,Context> env(argv[0], meta, meta_num,
391391
global_opt, global_opt_num, out, err);
392-
T request;
392+
Request request;
393393
int ret = CliParse(argc, argv, request, env);
394394
if(0 != ret){
395395
return ret;

0 commit comments

Comments
 (0)