Sha256: 1e9c10ab9b9bf59e64a2559a2a723b7fd65e35c461675dfc94b93d849a5e51d2

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env ruby
#
#  Created on 2008-5-11.
#  Copyright (c) 2008. All rights reserved.

begin
  require 'rubygems'
rescue LoadError
  # no rubygems to load, so we fail silently
end

require 'optparse'
require 'ftools'

# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.

OPTIONS = {
  :path     => '~',
  :speaking => false
}
MANDATORY_OPTIONS = %w(  )

parser = OptionParser.new do |opts|
  opts.banner = <<BANNER
This application is wonderful because...

Usage: #{File.basename($0)} [options]

Options are:
BANNER
  opts.separator ""
  
  opts.on("-p", "--path=PATH", String,
          "The root path for selecting files",
          "Default: ~") { |OPTIONS[:path]| }
          
  opts.on("-s", "--speaking",
           "If a test failed, the computer will speak.",
           "Only for Mac.") { |OPTIONS[:speaking]| OPTIONS[:speaking] = true }
          
  opts.on("-h", "--help",
          "Show this help message.") { puts opts; exit }
          
  opts.parse!(ARGV)

  if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
    puts opts; exit
  end
end

path = OPTIONS[:path]

f = File.new(File.expand_path(path) + "/.autotest",  "w")
f.write "# ~.autotest\n"
f.write "require 'autotest_notification'\n"
f.write("SPEAKING = #{OPTIONS[:speaking]}\n")
f.close
puts "\nAs from now all tests will be notified automatically."
puts "" # a blank line

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
carlosbrando-autotest-notification-1.0.0 bin/an-install
carlosbrando-autotest-notification-1.1.2 bin/an-install
urubatan-autotest-notification-1.0.1 bin/an-install