runtime: command: add an arg to begin_processing() to indicate pipeline position

This commit is contained in:
2026-06-13 13:40:20 +01:00
parent de5058e045
commit 4c04ca6de8
6 changed files with 65 additions and 20 deletions
+7 -12
View File
@@ -195,14 +195,15 @@ static enum bshell_status cmdcall_execute(struct bshell_cmdcall_p *cmdcall)
static enum bshell_status cmdcall_process_record(
struct bshell_cmdcall_p *cmdcall,
bshell_pipeline *pipeline,
struct bshell_runtime *rt)
struct bshell_runtime *rt,
enum bshell_command_position position)
{
if (!cmdcall->cmd_target) {
return BSHELL_ERR_NOT_SUPPORTED;
}
if (!cmdcall->cmd_initialised) {
bshell_command_begin_processing(cmdcall->cmd_target);
bshell_command_begin_processing(cmdcall->cmd_target, position);
cmdcall->cmd_initialised = true;
}
@@ -231,25 +232,19 @@ enum bshell_status bshell_cmdcall_resolve(
rt);
}
enum bshell_status bshell_cmdcall_execute(bshell_cmdcall *cmdcall)
{
FX_CLASS_DISPATCH_STATIC_0(
BSHELL_TYPE_CMDCALL,
cmdcall_execute,
cmdcall);
}
enum bshell_status bshell_cmdcall_process_record(
bshell_cmdcall *cmdcall,
bshell_pipeline *pipeline,
struct bshell_runtime *rt)
struct bshell_runtime *rt,
enum bshell_command_position position)
{
FX_CLASS_DISPATCH_STATIC(
BSHELL_TYPE_CMDCALL,
cmdcall_process_record,
cmdcall,
pipeline,
rt);
rt,
position);
}
FX_TYPE_CLASS_BEGIN(bshell_cmdcall)
+19 -1
View File
@@ -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;