diff options
author | Dickson S. Guedes | 2011-05-10 22:12:05 +0000 |
---|---|---|
committer | Dickson S. Guedes | 2011-05-10 22:12:05 +0000 |
commit | 7a423f986d914ba6a6c4297912489c84337719a7 (patch) | |
tree | 349155f9b2f45a02d754819f51a94d32641b6848 | |
parent | 609059c84410842a36db12d58b997865d0d9477e (diff) |
adding more options to create_extension and changind templates
-rw-r--r-- | lib/pgxn_utils/cli.rb | 38 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/%extension_name%.control.tt | 2 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/META.json.tt | 18 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/doc/%extension_name%.md | 0 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt | 4 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/sql/%extension_name%.sql | 0 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt | 6 |
7 files changed, 45 insertions, 23 deletions
diff --git a/lib/pgxn_utils/cli.rb b/lib/pgxn_utils/cli.rb index b8a2e48..9b8f229 100644 --- a/lib/pgxn_utils/cli.rb +++ b/lib/pgxn_utils/cli.rb @@ -1,23 +1,37 @@ module PgxnUtils class CLI < Thor - attr_accessor :extension_name - attr_accessor :author_name - attr_accessor :author_mail + attr_accessor :extension_name, :author_name, :author_mail + attr_accessor :short_description, :long_description, :tags include Thor::Actions - def self.source_root - @_source_root ||= File.expand_path('../templates', __FILE__) + desc "create_extension", "Creates an extension skeleton in current directory. Accepts a full path as extension name." + method_option :extension_name, :aliases => "-e", :required => true + method_option :author_name, :aliases => "-n", :type => :string, :default => "Your Name Here" + method_option :author_mail, :aliases => "-m", :type => :string, :default => "[email protected]" + method_option :tags, :aliases => "-t", :type => :array + method_option :short_description, :aliases => "-s", :type => :string, :default => "A short description" + method_option :long_description, :aliases => "-l", :type => :string , :default => "A long description" + + def create_extension + self.set_accessors + directory "root", extension_name end - desc "create_extension EXTENSION_PATH [AUTHOR_NAME] [AUTHOR_MAIL]", "Creates an extension skeleton in current directory. A full path is accepted." - def create_extension(extension_name, author_name="Your Name", author_mail="[email protected]") - self.destination_root = File.dirname(extension_name) || destination_root - self.extension_name = File.basename(extension_name) - self.author_name = author_name - self.author_mail = author_mail + no_tasks do + def set_accessors + self.destination_root = File.dirname(options[:extension_name]) || destination_root + self.extension_name = File.basename(options[:extension_name]) + self.author_name = options[:author_name] + self.author_mail = options[:author_mail] + self.tags = options[:tags] + self.short_description = options[:short_description] + self.long_description = options[:long_description] + end + end - directory "root", extension_name + def self.source_root + @_source_root ||= File.expand_path('../templates', __FILE__) end end end diff --git a/lib/pgxn_utils/templates/root/%extension_name%.control.tt b/lib/pgxn_utils/templates/root/%extension_name%.control.tt index 7024085..3430846 100644 --- a/lib/pgxn_utils/templates/root/%extension_name%.control.tt +++ b/lib/pgxn_utils/templates/root/%extension_name%.control.tt @@ -1,5 +1,5 @@ # <%= extension_name %> extension -comment = 'template' +comment = '<%= short_description %>' default_version = '1.0.0' module_pathname = '/<%= extension_name %>' relocatable = true diff --git a/lib/pgxn_utils/templates/root/META.json.tt b/lib/pgxn_utils/templates/root/META.json.tt index afbbe37..dad6da4 100644 --- a/lib/pgxn_utils/templates/root/META.json.tt +++ b/lib/pgxn_utils/templates/root/META.json.tt @@ -1,15 +1,15 @@ { "name": "<%= extension_name %>", - "abstract": "template", - "description": "A long description for <%= extension_name %>", + "abstract": "<%= short_description %>", + "description": "<%= long_description %>", "version": "1.0.0", "maintainer": [ - "<%= author_name %> \<<%= author_mail %>\>" + "<%= author_name %> <<%= author_mail %>>" ], "license": "postgresql", "provides": { "<%= extension_name %>": { - "abstract": "", + "abstract": "<%= short_description %>", "file": "sql/<%= extension_name %>.sql", "docfile": "doc/<%= extension_name %>.md", "version": "1.0.0" @@ -19,10 +19,8 @@ "meta-spec": { "version": "1.0.0", "url": "http://pgxn.org/meta/spec.txt" - }, - "tags": [ - "templ", - "some", - "tags" - ] + } + <% unless tags.nil? || tags.empty? %> + , "tags": [ <%= tags.collect { |t| %Q|"#{t}"| }.join(",") %> ] + <% end %> } diff --git a/lib/pgxn_utils/templates/root/doc/%extension_name%.md b/lib/pgxn_utils/templates/root/doc/%extension_name%.md deleted file mode 100644 index e69de29..0000000 --- a/lib/pgxn_utils/templates/root/doc/%extension_name%.md +++ /dev/null diff --git a/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt b/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt new file mode 100644 index 0000000..559137e --- /dev/null +++ b/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt @@ -0,0 +1,4 @@ +<%= extension_name %> +<%= extension_name.gsub(/./,"-") %> + +<%= long_description %> diff --git a/lib/pgxn_utils/templates/root/sql/%extension_name%.sql b/lib/pgxn_utils/templates/root/sql/%extension_name%.sql deleted file mode 100644 index e69de29..0000000 --- a/lib/pgxn_utils/templates/root/sql/%extension_name%.sql +++ /dev/null diff --git a/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt b/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt new file mode 100644 index 0000000..9e2c72a --- /dev/null +++ b/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt @@ -0,0 +1,6 @@ +/* + * Author: <%= author_name %> <<%= author_mail %>> + * Created at: <%= Time.now %> + * + */ + |