Class: Warg::Runner

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

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
# File 'lib/warg.rb', line 1523

def initialize(argv)
  @argv = argv.dup
  @path = nil
  @playlist = Playlist.new

  find_warg_directory!
  load_config!

  @context = Context.new(@argv, @playlist)
  @context.copy(Warg.config)

  load_scripts!
  load_commands!

  @command = Command.find(@argv)
end

Instance Method Details

#runObject



1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
# File 'lib/warg.rb', line 1540

def run
  if @command.nil?
    @context.parse_options!
    $stderr.puts "Could not find command from #{@argv.inspect}"
    exit 1
  end

  @command.(@context)
  @context.parse_options!

  Console.hostname_width = @context.hosts.map { |host| host.address.length }.max

  Warg.console.redirecting_stdout_and_stderr do
    @playlist.play
  end
end