-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Currently, if you call the same command multiple times, airbrussh doesn't really print out the right thing.
Below is some sample output, which I've annotated with the problems as I see them:
on_local("repeated_command_test") do
execute(:echo, "command 1")
execute(:echo, "command 1")
execute(:echo, "command 2")
execute(:echo, "command 1")
end
# output_lines :
" 01 echo command 1\n",
" 01 command 1\n",
" ✔ 01 test_user@localhost 0.004s\n",
# Missing start line and position number not incremented for Command 1 the second time
" 01 command 1\n", # Wrong position number for stdout, should be 2
" ✔ 01 test_user@localhost 0.004s\n", # Wrong position number for end line
" 02 echo command 2\n",
" 02 command 2\n",
" ✔ 02 test_user@localhost 0.003s\n",
# Missing start line and position number goes back to 1 for Command 1 the third time
" 01 command 1\n", # Wrong position number for stdout, should be 4
" ✔ 01 test_user@localhost 0.004s\n" # Wrong position number for end lineI propose to increment the command position in these cases, so it's clear which instance of the command the output belongs to. In order to achieve this, I'm thinking we could rely on the command uuid and enhance the command history to store all command executions, even if they have the same command string.
My idea is to modify the command history so it is never cleared. It would therefore be a complete command history rather than just being the history for the most recent task. I would store each command, in order as they are started. I would also store the current rake task against each command at the time the command is started.
I would then reimplement the methods which rely on the command history (eg first_execution, position, etc) using the new full command history.
As well as supporting repeated commands, I think this would make the code easier to reason about. At the moment I find the behaviour to do with clearing the history, storing the last task name and adding new commands hard to understand.
@mattbrictson Does this make sense? Should I look into this?