Class: CommandButler::LineDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/command_butler/line_decorator.rb

Class Method Summary collapse

Class Method Details

.decoration(command: command, index: index, current_index: current_index, input: input) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/command_butler/line_decorator.rb', line 3

def self.decoration(command:command, index:index, current_index: current_index, input: input)
  mark = if current_index == index
           "\e[33m" +  " > "
         elsif input
           "\e[32m" + (input.execute?? " o " : " - ")
         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