Parent

Launchy::Cli

Attributes

options[R]

Public Class Methods

new() click to toggle source
# File lib/launchy/cli.rb, line 7
def initialize
  @options = {}
end

Public Instance Methods

good_run( argv, env ) click to toggle source
# File lib/launchy/cli.rb, line 70
def good_run( argv, env )
  if parse( argv, env ) then
    Launchy.open( argv.shift, options )
    return true
  else
    return false
  end
end
parse( argv, env ) click to toggle source
# File lib/launchy/cli.rb, line 59
def parse( argv, env )
  begin
    parser.parse!( argv )
    return true
  rescue ::OptionParser::ParseError => pe
    $stderr.puts "#{parser.program_name}: #{pe}"
    $stderr.puts "Try `#{parser.program_name} --help for more information."
    return false
  end
end
parser() click to toggle source
# File lib/launchy/cli.rb, line 11
def parser
  @parser ||= OptionParser.new do |op|
    op.banner = "Usage: launchy [options] thing-to-launch"

    op.separator ""
    op.separator "Launch Options:"

    op.on( "-a", "--application APPLICATION", 
           "Explicitly specify the application class to use in the launch") do |app|
      @options[:application] = app
    end

    op.on( "-d", "--debug", 
           "Force debug. Output lots of information.") do |d|
      @options[:debug] = 'true'
    end

    op.on( "-e", "--engine RUBY_ENGINE",
           "Force launchy to behave as if it was on a particular ruby engine.") do |e|
      @options[:ruby_engine] = e
    end

    op.on( "-n", "--dry-run", "Don't launchy, print the command to be executed on stdout" ) do |x|
      @options[:dry_run] = true
    end

    op.on( "-o", "--host-os HOST_OS", 
           "Force launchy to behave as if it was on a particular host os.") do |os|
      @options[:host_os] = os
    end


    op.separator ""
    op.separator "Standard Options:"

    op.on( "-h", "--help", "Print this message.") do |h|
      $stdout.puts op.to_s
      exit 0
    end

    op.on( "-v", "--version", "Output the version of Launchy") do |v|
      $stdout.puts "Launchy version #{Launchy::VERSION}"
      exit 0
    end

  end
end
run( argv = ARGV, env = ENV ) click to toggle source
# File lib/launchy/cli.rb, line 79
def run( argv = ARGV, env = ENV )
  exit 1 unless good_run( argv, env )
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.