Sha256: 929f3e6943052df0cbb6c379952f954f45a21a9e520ceecb77d3831325a177c0

Contents?: true

Size: 1.54 KB

Versions: 22

Compression:

Stored size: 1.54 KB

Contents

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

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

    package_name Identity::VERSION_LABEL

    def self.configuration
      Runcom::Config.new "#{Identity::NAME}/configuration.yml"
    end

    def initialize args = [], options = {}, config = {}
      super args, options, config
      @configuration = self.class.configuration
    rescue Runcom::Errors::Base => error
      abort error.message
    end

    desc "-c, [--config]", "Manage gem configuration."
    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 = configuration.current

      if options.edit? then `#{ENV["EDITOR"]} #{path}`
      elsif options.info?
        path ? say(path) : say("Configuration doesn't exist.")
      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

    private

    attr_reader :configuration
  end
<% end %>

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
gemsmith-15.5.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-15.4.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-15.3.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-15.2.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-15.1.1 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-15.1.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-15.0.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.11.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.10.1 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.10.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.9.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.8.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.7.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.6.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.5.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.4.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.3.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.2.0 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.1.3 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt
gemsmith-14.1.2 lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt