Sha256: 7f38c095f4e2a356d893de02768352b1647c4a058a0870fde9b49944086751d3

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

require "cli_forge/autoload_convention"

module CLIForge
  extend CLIForge::AutoloadConvention

  def self.start(bin_name=nil, &block)
    config = CLIForge::DefaultConfiguration.new

    config.search_paths  = Array(caller_path(caller.first))
    config.search_paths += ENV["PATH"].split(":")
    config.search_paths.uniq!

    block.call(config) if block

    config.bin_name ||= bin_name || guess_bin_name

    CLIForge::Runner.new(config).start(ARGV)
  end

  def self.guess_bin_name
    File.basename($0)
  end

  def self.caller_path(stack_line)
    return unless stack_line
    stack_path = stack_line.split(":").first
    return if stack_path =~ /^\(.*\)$/

    File.expand_path(File.dirname(stack_path))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cli-forge-0.1.0 lib/cli_forge.rb