Sha256: 4284488f7da288c6ad2d6285f905e50e0ba0f2cc9e429db47d194ef03a586df4

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

require_relative '../source/core/create_helper'

module OrmDev
  class Command
    class Create < Command
      self.summary = '创建Orm插件模板工程。'

      self.description = <<-DESC
          新建 iOS => Application => Single View Application 工程,工程名为`NAME`

          zip插件模板创建:

          'ormdev create --template-url=http://112.65.142.83:7788/ceshi/tmpl/pod-fast-template.zip --fast Xxx'
      DESC

      self.arguments = [
          CLAide::Argument.new('NAME', true)
      ]

      def self.options
        [
            ['--template-url=URL', 'Orm插件模板git地址,或者zip地址'],
            ['--fast', '通过Orm插件模板工程zip地址快速创建'],
            ['--skip', '跳过打开Orm插件模板工程'],
        ].concat(super)
      end

      def initialize(argv)
        @name = argv.shift_argument
        @template_url = argv.option('template-url')
        @fast = argv.flag?('fast', false)
        @skip = argv.flag?('skip', false)
        super
      end

      def validate!
        super
        help! 'A name for the Pod is required.' unless @name
        help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
        help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
        help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
        unless @template_url.nil? then
          help! '模板地址只能是以[git|zip]结尾的地址.' if !(@template_url.downcase.end_with?('.git') || @template_url.downcase.end_with?('.zip'))
        end
      end

      def run
        create = OrmDev::CreateHelper.new(@name, @fast, @template_url)
        create.setup(@skip)
        OrmDev::LogUtil.info '【创建插件工程】Success!!!,编写插件逻辑代码,添加版本控制'
        OrmDev::LogUtil.info "   cd #{@name}".magenta
        OrmDev::LogUtil.info 'and'
        OrmDev::LogUtil.info "   ormdev run".magenta
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ormdev-0.2.3 lib/ormdev/command/create.rb
ormdev-0.2.2 lib/ormdev/command/create.rb
ormdev-0.2.1 lib/ormdev/command/create.rb
ormdev-0.2.0 lib/ormdev/command/create.rb