Sha256: b49dde287cf2a4bcaffd1a8d84dbbcc39e424386d1b47567cd02bef5c356b294

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 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 gem 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 gem 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 and super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-7.6.0 lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt