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.


1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
# File 'lib/warg.rb', line 1447

def initialize(argv)
  @argv = argv.dup
  @path = nil

  find_warg_directory!
  load_config!

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

  load_scripts!
  load_commands!

  @command = Command.find(@argv)
end

Instance Method Details

#runObject


1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
# File 'lib/warg.rb', line 1463

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

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

  Warg.console.redirecting_stdout_and_stderr do
    @context.run!
  end
end