Module: Kicker::Options

Defined in:
lib/kicker/options.rb

Overview

:nodoc:

Constant Summary collapse

DONT_SHOW_RECIPES =
%w{ could_not_handle_file execute_cli_command dot_kick }

Class Method Summary collapse

Class Method Details

.parse(argv) ⇒ Object



78
79
80
81
# File 'lib/kicker/options.rb', line 78

def self.parse(argv)
  parser.parse!(argv)
  Kicker.paths = argv unless argv.empty?
end

.parserObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/kicker/options.rb', line 37

def self.parser
  @parser ||= OptionParser.new do |opt|
    opt.banner =  "Usage: #{$0} [options] [paths to watch]"
    opt.separator " "
    opt.separator "  Available recipes: #{recipes_for_display.join(", ")}."
    opt.separator " "
    
    opt.on('-s', '--silent', 'Keep output to a minimum.') do |silent|
      Kicker.silent = true
    end
    
    opt.on('-q', '--quiet', "Quiet output. Don't print timestamps when logging.") do |quiet|
      Kicker.silent = Kicker.quiet = true
    end
    
    opt.on('-c', '--clear', "Clear console before each run.") do |clear|
      Kicker.clear_console = true
    end
    
    if Kicker::Growl.usable?
      opt.on('--[no-]growl', 'Whether or not to use Growl. Default is to use growl.') do |growl|
        Kicker::Growl.use = growl
      end
      
      opt.on('--growl-command [COMMAND]', 'The command to execute when the Growl succeeded message is clicked.') do |command|
        Kicker::Growl.command = command
      end
    else
      Kicker::Growl.use = false
    end
    
    opt.on('-l', '--latency [FLOAT]', "The time to collect file change events before acting on them. Defaults to #{Kicker.latency} second.") do |latency|
      Kicker.latency = Float(latency)
    end
    
    opt.on('-r', '--recipe [NAME]', 'A named recipe to load.') do |name|
      recipe(name)
    end
  end
end

.recipes_for_displayObject



33
34
35
# File 'lib/kicker/options.rb', line 33

def self.recipes_for_display
  Kicker::Recipes.recipe_files.map { |f| File.basename(f, '.rb') } - DONT_SHOW_RECIPES
end