docs:cli_parser
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| docs:cli_parser [2020/10/01 11:19] – root | docs:cli_parser [2020/10/01 11:34] (current) – root | ||
|---|---|---|---|
| Line 25: | Line 25: | ||
| void process_cmd( arg_node *cfg_cur, const char* command, size_t offset=0;) | void process_cmd( arg_node *cfg_cur, const char* command, size_t offset=0;) | ||
| { | { | ||
| + | size_t kwd_len=0; | ||
| size_t arg_len=0; | size_t arg_len=0; | ||
| - | char* arg = command+offset; | + | char* keyword |
| + | char* arg = null; | ||
| | | ||
| // Search the next argument boundary | // Search the next argument boundary | ||
| - | while( | + | while( |
| - | ++arg_len; | + | ++kwd_len; |
| | | ||
| // If we don't have an argument, attempt to call the node's callback method. | // If we don't have an argument, attempt to call the node's callback method. | ||
| - | if( arg_len | + | if( kwd_len |
| { | { | ||
| - | if( cfg_cur-> | + | if( cfg_cur-> |
| { | { | ||
| cfg_cur-> | cfg_cur-> | ||
| Line 45: | Line 47: | ||
| return; | return; | ||
| + | } | ||
| + | | ||
| + | if ( cfg_cur-> | ||
| + | { | ||
| + | // This node has an argument. | ||
| + | | ||
| + | arg = command+offset+kwd_len+1; | ||
| + | | ||
| + | // Attempt to get the size of the argument | ||
| + | while( arg[kwd_len] != ' | ||
| + | ++arg_len; | ||
| + | | ||
| + | if( arg_len == 0 ) | ||
| + | { | ||
| + | Serial.print( F(" | ||
| + | return; | ||
| + | } | ||
| } | } | ||
| | | ||
| Line 51: | Line 70: | ||
| for( size_t i=0; i< | for( size_t i=0; i< | ||
| { | { | ||
| - | if( strncmp( cfg_cur-> | + | if( strncmp( cfg_cur-> |
| { | { | ||
| // Positive match | // Positive match | ||
| - | process_cmd( cfg_cur-> | + | process_cmd( cfg_cur-> |
| return; | return; | ||
| } | } | ||
docs/cli_parser.1601543981.txt.gz · Last modified: 2020/10/01 11:19 by root