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

Inherits:
CLAide::Command::Plugins show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Create

Returns a new instance of Create.



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

def initialize(argv)
  @name = argv.shift_argument
  prefix = CLAide::Plugins.config.plugin_prefix + '-'
  unless @name.nil? || @name.empty? || @name.start_with?(prefix)
    @name = prefix + @name.dup
  end
  @template_url = argv.shift_argument
  super
end

Class Method Details

.descriptionObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/claide/command/plugins/create.rb', line 14

def self.description
  <<-DESC
        Creates a scaffold for the development of a new plugin
        named `NAME` according to the best practices.

        If a `TEMPLATE_URL`, pointing to a git repo containing a
        compatible template, is specified, it will be used
        in place of the default one.
  DESC
end

Instance Method Details

#runObject



49
50
51
52
53
54
# File 'lib/claide/command/plugins/create.rb', line 49

def run
  runner = TemplateRunner.new @name, @template_url
  runner.clone_template
  runner.configure_template
  show_reminder
end

#validate!Object



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

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