Class: Shoes::UI::CLI::DefaultCommand

Inherits:
BaseCommand show all
Defined in:
shoes-core/lib/shoes/ui/cli/default_command.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#args

Instance Method Summary collapse

Methods inherited from BaseCommand

#help_from_options, #initialize, #parse!, #warn_on_unexpected_parameters

Constructor Details

This class inherits a constructor from Shoes::UI::CLI::BaseCommand

Instance Method Details

#helpObject



40
41
42
# File 'shoes-core/lib/shoes/ui/cli/default_command.rb', line 40

def help
  help_from_options("shoes [options] file", options)
end

#optionsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'shoes-core/lib/shoes/ui/cli/default_command.rb', line 20

def options
  OptionParser.new do |opts|
    # Keep around command dashed options
    opts.on('-v', '--version', 'Shoes version') do
      Shoes::UI::CLI::VersionCommand.new([]).run
      exit
    end

    opts.on('-h', '--help', 'Shoes help') do
      Shoes::UI::CLI::HelpCommand.new([]).run
      exit
    end

    # Also, we have some real runtime options!
    opts.on('-f', '--fail-fast', 'Crash on exceptions in Shoes code') do
      Shoes.configuration.fail_fast = true
    end
  end
end

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'shoes-core/lib/shoes/ui/cli/default_command.rb', line 7

def run
  return unless parse!(args)

  warn_on_unexpected_parameters
  path = args.first

  return unless path

  $LOAD_PATH.unshift(File.dirname(path))
  Shoes.configuration.app_dir = File.dirname(path)
  load path
end