From 3e3b50586dc05e3952f571dfa3a38dceaabbdf7c Mon Sep 17 00:00:00 2001 From: Tom Greig <tom@tomg.xyz> Date: Fri, 11 Apr 2025 10:13:55 +0100 Subject: [PATCH] Add -p option to print data as it comes in Allows you to do stuff like $ get data | e-plot -p > data_file.csv --- src/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.c b/src/main.c index eab74d8..6665290 100644 --- a/src/main.c +++ b/src/main.c @@ -103,6 +103,8 @@ struct context { bool sort; + bool print; + char* xaxis; size_t xaxis_n; @@ -324,6 +326,13 @@ int main( int argc, char** argv ) { .arg = G_OPTION_ARG_NONE, .arg_data = &( context->time ), .description = "Format x-axis as time", + }, { + .long_name = "print", + .short_name = 'p', + .flags = G_OPTION_FLAG_IN_MAIN, + .arg = G_OPTION_ARG_NONE, + .arg_data = &( context->print ), + .description = "Copy input to stdout", }, { NULL, }, @@ -1087,6 +1096,9 @@ static int data_callback( void* data ) { context->read_buffer + strlen( context->read_buffer ), buffer, l + 1 ); + if ( context->print ) { + write( STDOUT_FILENO, buffer, l ); + } } -- GitLab