diff options
Diffstat (limited to 'src/cli.c')
-rw-r--r-- | src/cli.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -91,7 +91,15 @@ static void get_workers( ) free( data ); return; } - worker_names[nof_worker_names++] = strdup( p + 1 ); + bool duplicate = false; + for( int j = 0; j < nof_worker_names; j++ ) { + if( strcmp( worker_names[j], p + 1 ) == 0 ) { + duplicate = true; + } + } + if( !duplicate ) { + worker_names[nof_worker_names++] = strdup( p + 1 ); + } *pp = s; line = strtok( NULL, "\n" ); } @@ -103,7 +111,12 @@ static void get_workers( ) static void print_workers( ) { - puts( "available workers..." ); + printf( "available workers: " ); + for( int i = 0; i < nof_worker_names; i++ ) { + if( i != 0 ) printf( " " ); + printf( worker_names[i] ); + } + puts( "" ); } static void completion_func( const char *buf, linenoiseCompletions *lc ) @@ -126,6 +139,7 @@ static void completion_func( const char *buf, linenoiseCompletions *lc ) case STOP_WORKER: case MESSAGES_WORKER: get_workers( ); + print_workers( ); for( int i = 0; i < nof_worker_names; i++ ) { linenoiseAddCompletion( lc, worker_names[i] ); } |