Class: TTY::Command::DryRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/command/dry_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd, printer) ⇒ DryRunner

Returns a new instance of DryRunner.



10
11
12
13
# File 'lib/tty/command/dry_runner.rb', line 10

def initialize(cmd, printer)
  @cmd     = cmd
  @printer = printer
end

Instance Attribute Details

#cmdObject (readonly)

Returns the value of attribute cmd.



8
9
10
# File 'lib/tty/command/dry_runner.rb', line 8

def cmd
  @cmd
end

Instance Method Details

#run!Object

Show command without running



18
19
20
21
22
23
24
# File 'lib/tty/command/dry_runner.rb', line 18

def run!(*)
  cmd.to_command
  message = "#{@printer.decorate("(dry run)", :blue)} " +
            @printer.decorate(cmd.to_command, :yellow, :bold)
  @printer.write(cmd, message, cmd.uuid)
  Result.new(0, "", "")
end