runtime: command: add an arg to begin_processing() to indicate pipeline position
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <fx/vector.h>
|
||||
|
||||
struct bshell_pipeline_p {
|
||||
bool p_input_values_provided;
|
||||
bshell_pipeline *p_self;
|
||||
fx_array *p_in, *p_out;
|
||||
FX_VECTOR_DECLARE(bshell_cmdcall *, p_cmds);
|
||||
@@ -72,6 +73,7 @@ static enum bshell_status pipeline_add_input_value(
|
||||
fx_value value,
|
||||
bool enumerate)
|
||||
{
|
||||
pipeline->p_input_values_provided = true;
|
||||
return write_value(pipeline, pipeline->p_in, value, enumerate);
|
||||
}
|
||||
|
||||
@@ -118,10 +120,26 @@ static enum bshell_status pipeline_pump_record(
|
||||
|
||||
size_t i = 0;
|
||||
for (i = 0; i < pipeline->p_cmds.count;) {
|
||||
enum bshell_command_position position;
|
||||
if (pipeline->p_cmds.count == 1) {
|
||||
position = pipeline->p_input_values_provided
|
||||
? BSHELL_COMMAND_POSITION_END
|
||||
: BSHELL_COMMAND_POSITION_SINGLE;
|
||||
} else if (i == 0) {
|
||||
position = pipeline->p_input_values_provided
|
||||
? BSHELL_COMMAND_POSITION_END
|
||||
: BSHELL_COMMAND_POSITION_BEGINNING;
|
||||
} else if (i == pipeline->p_cmds.count - 1) {
|
||||
position = BSHELL_COMMAND_POSITION_END;
|
||||
} else {
|
||||
position = BSHELL_COMMAND_POSITION_MIDDLE;
|
||||
}
|
||||
|
||||
status = bshell_cmdcall_process_record(
|
||||
pipeline->p_cmds.items[i],
|
||||
pipeline->p_self,
|
||||
rt);
|
||||
rt,
|
||||
position);
|
||||
|
||||
if (status != BSHELL_SUCCESS) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user