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.



1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/warg.rb', line 1434

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



1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
# File 'lib/warg.rb', line 1451

def run
  if @command.nil?
    $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