lib/pod/command/plugins/create.rb in cocoapods-plugins-0.1.1 vs lib/pod/command/plugins/create.rb in cocoapods-plugins-0.2.0
- old
+ new
@@ -4,24 +4,32 @@
# The create subcommand. Used to create a new plugin using either the
# default template (CocoaPods/cocoapods-plugin-template) or a custom
# template
#
class Create < Plugins
+ NAME_PREFIX = 'cocoapods-'
+
self.summary = 'Creates a new plugin'
self.description = <<-DESC
Creates a scaffold for the development of a new plugin
according to the CocoaPods 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
- self.arguments = 'NAME [TEMPLATE_URL]'
+ self.arguments = [
+ ['NAME', :required],
+ ['TEMPLATE_URL', :optional]
+ ]
def initialize(argv)
@name = argv.shift_argument
+ unless @name.nil? || @name.empty? || @name.index(NAME_PREFIX) == 0
+ @name = @name.dup.prepend(NAME_PREFIX)
+ end
@template_url = argv.shift_argument
super
end
def validate!
@@ -57,20 +65,21 @@
# the name of the plugin.
#
# @return [void]
#
def clone_template
- UI.section("Creating `#{@name}` plugin") do
+ UI.section("-> Creating `#{@name}` plugin") do
+ UI.notice "using template '#{template_repo_url}'"
git! "clone '#{template_repo_url}' #{@name}"
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def configure_template
- UI.section('Configuring template') do
+ UI.section('-> Configuring template') do
Dir.chdir(@name) do
if File.file? 'configure'
system "./configure #{@name}"
else
UI.warn 'Template does not have a configure file.'