Sha256: d7cbb6e2a2757ba9636635de1c54edfbc54741f0d12a429da973936203f85eb2

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

class Lono::CLI::New
  class Helper < Lono::CLI::New::Sequence
    def self.cli_options
      # required for name => underscore_name => app/blueprints/demo/helpers/%underscore_name%_helper.rb.tt
      argument :name, default: "custom", desc: "Helper name"

      [
        [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
        [:blueprint, aliases: :b, desc: "Blueprint name. Only use you want a blueprint helper. Otherwise a project helper is generated"],
      ]
    end
    cli_options.each do |args|
      class_option(*args)
    end

    def set_source
      set_template_source "helper"
    end

    def create_helper
      if @options[:blueprint]
        create_blueprint_helper
      else
        create_project_helper
      end
    end

  private
    def create_blueprint_helper
      @blueprint = @options[:blueprint] # allows %underscore_name%_helper.rb.tt to access @blueprint
      logger.info "=> Generating #{underscore_name}_helper.rb"
      directory ".", "app/blueprints/#{@blueprint}/helpers"
    end

    def create_project_helper
      logger.info "=> Generating #{underscore_name}_helper.rb"
      directory ".", "app/helpers/#{underscore_name}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/cli/new/helper.rb
lono-8.0.0.pre.rc5 lib/lono/cli/new/helper.rb
lono-8.0.0.pre.rc4 lib/lono/cli/new/helper.rb