Class: OrmDev::Command::Create

Inherits:
OrmDev::Command show all
Defined in:
lib/ormdev/command/create.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Create

Returns a new instance of Create.



25
26
27
28
29
30
31
32
# File 'lib/ormdev/command/create.rb', line 25

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

Class Method Details

.optionsObject



16
17
18
19
20
21
22
23
# File 'lib/ormdev/command/create.rb', line 16

def self.options
  [
      ['--template-url=URL', 'Orm插件模板git地址'],
      ['--fast', '快速创建Orm插件模板工程(带测试用例)'],
      ['--prefix=XXX', 'Orm插件模板工程前缀(fast有效)'],
      ['--skip', '跳过打开Orm插件模板工程(fast有效)'],
  ].concat(super)
end

Instance Method Details

#runObject



42
43
44
45
46
47
48
49
# File 'lib/ormdev/command/create.rb', line 42

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

#validate!Object



34
35
36
37
38
39
40
# File 'lib/ormdev/command/create.rb', line 34

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] == '.'
end