Class: CLAide::Command::Plugins::Create

Inherits:
CLAide::Command::Plugins show all
Extended by:
Executable
Defined in:
lib/claide/command/plugins/create.rb

Overview

The create subcommand. Used to create a new plugin using either the default template (CocoaPods/cocoapods-plugin-template) or a custom template

Constant Summary collapse

NAME_PREFIX =
'claide-'

Instance Method Summary collapse

Methods included from Executable

executable, execute_command

Constructor Details

#initialize(argv) ⇒ Create

Returns a new instance of Create.



29
30
31
32
33
34
35
36
# File 'lib/claide/command/plugins/create.rb', line 29

def initialize(argv)
  @name = argv.shift_argument
  unless @name.nil? || @name.empty? || @name.start_with?(NAME_PREFIX)
    @name = NAME_PREFIX + @name.dup
  end
  @template_url = argv.shift_argument
  super
end

Instance Method Details

#runObject



47
48
49
50
51
# File 'lib/claide/command/plugins/create.rb', line 47

def run
  clone_template
  configure_template
  show_reminder
end

#validate!Object



38
39
40
41
42
43
44
45
# File 'lib/claide/command/plugins/create.rb', line 38

def validate!
  super
  if @name.nil? || @name.empty?
    help! 'A name for the plugin is required.'
  end

  help! 'The plugin name cannot contain spaces.' if @name.match(/\s/)
end