3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/command_butler/line_decorator.rb', line 3
def self.decoration(command:command, index:index, current_index: current_index, history: history)
mark = if current_index == index
"\e[33m" + " > "
elsif history
if history[:result]
history[:result][:status].success?? "\e[32m" + " o " : "\e[31m" + " x "
else
"\e[32m" + (history[:input].execute?? " o " : " - ")
end
else
"\e[37m" + " "
end
ret = "#{index + 1} " + "["+ mark + "\e[0m" + "]"
if command.command ret += " " + command.command
else
ret += " - "
end
ret += " <= chdir to #{command.chdir}" if command.chdir ret
end
|