app/commands/new.rb in skippy-0.2.0.a vs app/commands/new.rb in skippy-0.3.0.a
- old
+ new
@@ -7,17 +7,29 @@
class New < Skippy::Command::Group
include Thor::Actions
argument :namespace,
- :type => :string,
- :desc => 'The namespace the extension will use'
+ type: :string,
+ desc: 'The namespace the extension will use'
+ class_option :basename,
+ aliases: ['-b'],
+ type: :string,
+ desc: 'The basename for the extension filename'
+
+ class_option :downcase,
+ aliases: ['-d'],
+ type: :boolean,
+ desc: 'Downcase the generated basename for the extension filename',
+ default: false
+
class_option :template,
- :type => :string,
- :desc => 'The template used to generate the project files',
- :default => 'standard'
+ aliases: ['-t'],
+ type: :string,
+ desc: 'The template used to generate the project files',
+ default: 'standard'
source_paths << Skippy.app.resources
attr_reader :project
@@ -26,10 +38,12 @@
if project.exist?
raise Skippy::Error, "A project already exist: #{project.filename}"
end
project.namespace = namespace
project.name = project.namespace.to_name
+ project.basename = options[:basename] || project.namespace.short_name
+ project.basename = project.basename.downcase if options[:downcase]
end
def validate_template
template_path = File.join(self.class.source_root, options[:template])
unless File.directory?(template_path)
@@ -58,16 +72,16 @@
name: project.name,
description: project.description,
creator: project.author,
copyright: project.copyright,
license: project.license,
- product_id: project.namespace.to_a.join('_'),
+ product_id: project.namespace.short_name,
version: '0.1.0',
build: '1',
}
json = JSON.pretty_generate(extension_info)
- json_filename = "src/#{project.namespace.to_underscore}/extension.json"
+ json_filename = "src/#{ext_name}/extension.json"
create_file(json_filename, json)
end
def create_example_skippy_command
copy_file('commands/example.rb', 'skippy/commands/example.rb')
@@ -82,10 +96,10 @@
# templates and expands the filenames.
no_commands do
# @return [String] The basename for the extension files.
def ext_name
- project.namespace.to_underscore
+ project.basename
end
end # no_commands
# Needed as base for Thor::Actions' file actions.