From 1f53cc0acfc0552172f2b142910f10def4ff0e61 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 12 Jun 2015 13:49:36 +0200 Subject: temporary checkin --- src/cli.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cli.c b/src/cli.c index 3f8f903..aa2d169 100644 --- a/src/cli.c +++ b/src/cli.c @@ -27,8 +27,9 @@ typedef enum { COMMAND, // command parsing - START_WORKER, // worker command expecting a worker parameter - STOP_WORKER + START_WORKER, // worker commands expect a worker (and + STOP_WORKER, // optionally an architecture and os parameter) + MESSAGES_WORKER } command_state_t; static char *commands[] = { @@ -100,6 +101,11 @@ static void get_workers( ) free( data ); } +static void print_workers( ) +{ + puts( "available workers..." ); +} + static void completion_func( const char *buf, linenoiseCompletions *lc ) { unsigned int i; @@ -118,6 +124,7 @@ static void completion_func( const char *buf, linenoiseCompletions *lc ) case START_WORKER: case STOP_WORKER: + case MESSAGES_WORKER: get_workers( ); for( int i = 0; i < nof_worker_names; i++ ) { linenoiseAddCompletion( lc, worker_names[i] ); @@ -301,6 +308,7 @@ int start_interactive( bool colors, const char *host, unsigned short port, FILE case START_WORKER: case STOP_WORKER: + case MESSAGES_WORKER: context = "worker"; break; } @@ -320,6 +328,7 @@ int start_interactive( bool colors, const char *host, unsigned short port, FILE case START_WORKER: case STOP_WORKER: + case MESSAGES_WORKER: command_state = COMMAND; continue; } @@ -363,7 +372,7 @@ int start_interactive( bool colors, const char *host, unsigned short port, FILE } else if( strncasecmp( line, "stop", 5 ) == 0 ) { command_state = STOP_WORKER; } else if( strncasecmp( line, "messages", 8 ) == 0 ) { - print_messages( ); + command_state = MESSAGES_WORKER; } else if( strncasecmp( line, "autodisp", 8 ) == 0 ) { if( is_interactive ) { autodisp_toggle = !autodisp_toggle; @@ -387,6 +396,11 @@ int start_interactive( bool colors, const char *host, unsigned short port, FILE stop_worker( line ); command_state = COMMAND; break; + + case MESSAGES_WORKER: + print_messages( ); + command_state = COMMAND; + break; } } -- cgit v1.2.3-54-g00ecf