Sha256: 13a6233b0df7bcf46f77f66b4fa1022cf2196cb6ad04b1f41f773edb6189db93

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

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

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

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

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

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

    desc "-v, [--version]", "Show #{<%= config.dig(:gem, :class) %>::Identity.label} version."
    map %w(-v --version) => :version
    def version
      say <%= config.dig(:gem, :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

6 entries across 6 versions & 1 rubygems

Version Path
gemsmith-7.5.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-7.4.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-7.3.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-7.2.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-7.1.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
gemsmith-7.0.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt