Class: Jasminewebos::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/jasminewebos/cli.rb

Class Method Summary collapse

Class Method Details

.execute(stdout, arguments = []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jasminewebos/cli.rb', line 6

def self.execute(stdout, arguments=[])
  command = ""
  mandatory_options = %w(  )
  
  generate = false
  start_server = false
  
  parser = OptionParser.new do |opts|
    opts.banner = <<-BANNER.gsub(/^          /,'')
      Tools for working with jasmine_webos

      Usage: 
      #{File.basename($0)} -g
      generates the jasmine files in the current directory
      
      #{File.basename($0)} -s
      starts the jasmine server from the current directory
      
      Options:
    BANNER
    opts.separator ""
    opts.on("-g", String,
            "Starts the jasmine server from the current directory") { generate = true }
    opts.on("-s", String,
            "Generate the jasmine files in the current directory") { start_server = true }
    opts.on("-h", "--help",
            "Show this help message.") { stdout.puts opts; exit }
    opts.parse!(arguments)
    
    if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
      stdout.puts opts; exit
    end
  end
  
  config = Jasminewebos::Configuration.new(FileUtils.pwd)
  
  self.generate_stub(config) if generate
  self.launch_server(config) if start_server
  
end

.generate_stub(config) ⇒ Object



47
48
49
50
51
# File 'lib/jasminewebos/cli.rb', line 47

def self.generate_stub(config)
  puts("Generating jasmine_webos required files")
  Jasminewebos::Generator.new(config).run
  puts("  Complete.")
end

.launch_server(config) ⇒ Object



53
54
55
# File 'lib/jasminewebos/cli.rb', line 53

def self.launch_server(config)
  Jasminewebos::Server.new(config).start
end