Sha256: f6925d0e8b78d51f91a3bd8cea3c0dc2a629a00d961438beb41585164b6016e3

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby -W

# weexb create demo

require_relative 'project'

module WeexBuilder
  class Runner
    def initialize(args)
      @args = args
    end
      
    # create
    # platform add ios/android 
    def exec 
      return usage if @args.length == 0
      
      case @args.first
      when 'create'
        return action_usage(@args.first) unless @args.length == 2
        WeexBuilder::Project.create(@args[1])
      when 'platform'
        return action_usage(@args.first) unless @args.length == 3
        return action_usage(@args.first) unless @args[1] == 'add' && /^(iOS|android)$/i =~ @args[2] 

        WeexBuilder::Project.add_platform(@args[2])
      else 
        usage
      end
    end

    private 

    def action_usage(name)
      case name
      when 'create'
        puts 'Please Use: weexbuilder create YOUR_PROJECTNAME'
      when 'platform'
        puts 'Please Use: weexbuilder platform add iOS/android'
      else 
        usage
      end
    end

    def usage
      puts <<-"..."
Usage:
    
    $ weexbuilder COMMAND [ACTION]

Commands:

    + create    Create a new weex Project
    + platform  

      ...
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
weexbuilder-0.0.4 lib/runner.rb
weexbuilder-0.0.3 lib/runner.rb
weexbuilder-0.0.2 lib/runner.rb
weexbuilder-0.0.1 lib/runner.rb