Sha256: 78aeb748c6697164e1af7e42f1357f183fff4f62c967fdb2947bbbf9e0c91d52

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

require "thor"
require "thor/actions"
require "thor_plus/actions"
require "runcom"

<% render_namespace do %>
  # The Command Line Interface (CLI) for the gem.
  class CLI < Thor
    include Thor::Actions
    include ThorPlus::Actions

    package_name Identity.version_label

    def self.configuration
      Runcom::Configuration.new file_name: Identity.file_name
    end

    def initialize args = [], options = {}, config = {}
      super args, options, config
    end

    desc "-c, [--config]", %(Manage gem configuration ("#{configuration.computed_path}").)
    map %w[-c --config] => :config
    method_option :edit,
                  aliases: "-e",
                  desc: "Edit gem configuration.",
                  type: :boolean, default: false
    method_option :info,
                  aliases: "-i",
                  desc: "Print gem configuration.",
                  type: :boolean, default: false
    def config
      path = self.class.configuration.computed_path

      if options.edit? then `#{editor} #{path}`
      elsif options.info? then say(path)
      else help(:config)
      end
    end

    desc "-v, [--version]", "Show gem version."
    map %w[-v --version] => :version
    def version
      say Identity.version_label
    end

    desc "-h, [--help=COMMAND]", "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

9 entries across 9 versions & 1 rubygems

Version Path
gemsmith-9.6.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-9.5.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-9.4.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-9.3.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-9.2.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-9.1.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-9.0.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-8.2.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-8.1.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt