Skip to content

Commit 4406d92

Browse files
authored
Avoid storing characters before finishing execution of echo command (#118)
* Avoid storing characters before finishing execution of echo command Signed-off-by: Denisa <[email protected]> * Enable ANS characters in windows Signed-off-by: Denisa <[email protected]> * Fix printing bug Signed-off-by: Denisa <[email protected]> * Change sleep duration in print_command Signed-off-by: Denisa <[email protected]> * fix tests Signed-off-by: Denisa <[email protected]> * Fix python linter Signed-off-by: Denisa <[email protected]> * Fix linter 2 Signed-off-by: Denisa <[email protected]> * fix linter 3 Signed-off-by: Denisa <[email protected]> --------- Signed-off-by: Denisa <[email protected]>
1 parent 9a794c0 commit 4406d92

26 files changed

+172
-95
lines changed

fastddsspy_tool/src/cpp/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ int main(
5151
int argc,
5252
char** argv)
5353
{
54+
// Enable ANSI colors fow windows
55+
eprosima::utils::enable_ansi_colors();
5456
// Initialize CommandlineArgs
5557
eprosima::spy::yaml::CommandlineArgsSpy commandline_args;
5658

fastddsspy_tool/src/cpp/tool/Controller.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,13 @@ void Controller::print_command_(
492492
}
493493

494494
// Wait for other command to stop printing topics
495+
input_.stdin_handler().set_ignore_input(true);
495496
input_.wait_something();
497+
input_.stdin_handler().set_ignore_input(false);
496498
model_->deactivate();
499+
500+
// Small delay to allow stdout to flush and avoid prompt overlap
501+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
497502
}
498503

499504
void Controller::version_command_(

fastddsspy_tool/src/cpp/tool/Input.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class Input
3737
protected:
3838

3939
utils::CommandReader<CommandValue> reader_;
40+
41+
public:
42+
43+
/**
44+
* @brief Access the underlying stdin event handler to control input behavior.
45+
* Used for temporarily disabling history input (e.g., during interactive commands).
46+
*/
47+
eprosima::utils::event::StdinEventHandler& stdin_handler() noexcept
48+
{
49+
return reader_.stdin_handler();
50+
}
51+
4052
};
4153

4254
} /* namespace spy */

fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def __init__(self):
4141
arguments_spy=['--config-path', 'configuration', 'datareader',
4242
'01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'],
4343
commands_spy=[],
44-
output="""\x1b[1;31m01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \
45-
does not match with any known reader.\x1b[0m\n"""
44+
output="""01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \
45+
does not match with any known reader.\n"""
4646
)

fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def __init__(self):
4141
arguments_spy=['--config-path', 'configuration', 'datawriter',
4242
'01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'],
4343
commands_spy=[],
44-
output="""\x1b[1;31m01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \
45-
does not match with any known writer.\x1b[0m\n"""
44+
output="""01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \
45+
does not match with any known writer.\n"""
4646
)

fastddsspy_tool/test/application/test_cases/one_shot_null.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def __init__(self):
3636
arguments_dds=[],
3737
arguments_spy=['nullarg'],
3838
commands_spy=[],
39-
output="""\x1b[1;31m<nullarg> is not a known command. \
40-
Use <help> command to see valid commands and arguments.\x1b[0m\n"""
39+
output="""<nullarg> is not a known command. \
40+
Use <help> command to see valid commands and arguments.\n"""
4141
)

fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def __init__(self):
4141
arguments_spy=['--config-path', 'configuration', 'participant',
4242
'01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'],
4343
commands_spy=[],
44-
output="""\x1b[1;31m01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \
45-
does not match with any known participant.\x1b[0m\n"""
44+
output="""01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \
45+
does not match with any known participant.\n"""
4646
)

fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def __init__(self):
3636
arguments_dds=[],
3737
arguments_spy=['show'],
3838
commands_spy=[],
39-
output="""\x1b[1;31mCommand <show> requires at least \
40-
one argument.\x1b[0m\n"""
39+
output="""Command <show> requires at least \
40+
one argument.\n"""
4141
)

fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ def __init__(self):
3636
arguments_dds=[],
3737
arguments_spy=['show', 'hello'],
3838
commands_spy=[],
39-
output="""\x1b[1;31m<hello> does not match any topic discovered.\x1b[0m\n"""
39+
output="""<hello> does not match any topic discovered.\n"""
4040
)

fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ def __init__(self):
3636
arguments_dds=[],
3737
arguments_spy=['show', 'hello', 'verbose'],
3838
commands_spy=[],
39-
output="""\x1b[1;31m<hello> does not match any topic discovered.\x1b[0m\n"""
39+
output="""<hello> does not match any topic discovered.\n"""
4040
)

0 commit comments

Comments
 (0)