Sha256: 17ee5d950ed4629ad804e49c0077d78114ce58e82cffd629493d608eac942793

Contents?: true

Size: 1.63 KB

Versions: 6

Compression:

Stored size: 1.63 KB

Contents

require 'optparse'
require 'fileutils'

module Jasminewebos
  class CLI
    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
    
    def self.generate_stub(config)
      puts("Generating jasmine_webos required files")
      Jasminewebos::Generator.new(config).run
      puts("  Complete.")
    end
    
    def self.launch_server(config)
      Jasminewebos::Server.new(config).start
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gaffo-jasmine_webos-0.0.1 lib/jasminewebos/cli.rb
gaffo-jasmine_webos-0.0.2 lib/jasminewebos/cli.rb
gaffo-jasmine_webos-0.0.3 lib/jasminewebos/cli.rb
gaffo-jasmine_webos-0.0.4 lib/jasminewebos/cli.rb
jasmine_webos-0.0.8 lib/jasminewebos/cli.rb
jasmine_webos-0.0.6 lib/jasminewebos/cli.rb