Sha256: 32f3efa7432051e79345fb05ec5729299b8952923d43132cf61b414365166e4b

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require "yaml"
require "thor"
require "thor/actions"
require "thor_plus/actions"

module <%= config.fetch(:gem).fetch(:class) %>
  # The Command Line Interface (CLI) for the gem.
  class CLI < Thor
    include Thor::Actions
    include ThorPlus::Actions

    package_name <%= config.fetch(:gem).fetch(:class) %>::Identity.version_label

    def initialize args = [], options = {}, config = {}
      super args, options, config
    end
    <%- if config.fetch(:create).fetch(:cli) -%>

    desc "-e, [--edit]", "Edit #{<%= config.fetch(:gem).fetch(:class) %>::Identity.label} settings in default editor."
    map %w(-e --edit) => :edit
    def edit
      `#{editor} $HOME/#{<%= config.fetch(:gem).fetch(:class) %>::Identity.file_name}`
    end
    <%- end -%>

    desc "-v, [--version]", "Show #{<%= config.fetch(:gem).fetch(:class) %>::Identity.label} version."
    map %w(-v --version) => :version
    def version
      say <%= config.fetch(:gem).fetch(:class) %>::Identity.version_label
    end

    desc "-h, [--help=HELP]", "Show this message or get help for a command."
    map %w(-h --help) => :help
    def help task = nil
      say && super
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemsmith-6.2.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-6.1.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-6.0.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt