From 1f53cc0acfc0552172f2b142910f10def4ff0e61 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 12 Jun 2015 13:49:36 +0200 Subject: temporary checkin --- TODOS | 4 ++-- src/cli.c | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/TODOS b/TODOS index d3683d0..788a82f 100644 --- a/TODOS +++ b/TODOS @@ -21,5 +21,5 @@ systems? most likely we have to build something on our own. Last resort is that a biruda on for instance FreeBSD just reboots back to Linux (one shot grub2 menu entry selection and boot and then falling back) - - +- cli: + - have nicer error messages than "ERROR: HTTP error -3 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