Sha256: 243ec79a11c31dcb70d870c7da5cfcf893e68b9d5322321095268b4f48f97a04

Contents?: true

Size: 886 Bytes

Versions: 8

Compression:

Stored size: 886 Bytes

Contents

module Runbook::Generators
  module Base
    def self.included(base)
      base.extend(ClassMethods)
      base.include(Thor::Actions)

      set_base_options(base)
      base.check_unknown_options!
    end

    def self.set_base_options(base)
      base.class_option(
        :root,
        group: :base,
        default: ".",
        desc: "The root directory for your generated code",
      )
      base.add_runtime_options!
    end

    module ClassMethods
      def command
        self.to_s.gsub("Runbook::Generators::", "").underscore
      end

      def usage
        args = arguments.map(&:banner).join(" ")
        args += " " unless args.empty?
        "#{command} #{args}[options]"
      end

      def description
        "Generate a #{command}"
      end

      def long_description
        description
      end

      def options
        {}
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
careacademy-runbook-1.2.0 lib/runbook/generators/base.rb
runbook-1.1.0 lib/runbook/generators/base.rb
runbook-1.0.0 lib/runbook/generators/base.rb
runbook-0.16.1 lib/runbook/generators/base.rb
runbook-0.16.0 lib/runbook/generators/base.rb
runbook-0.15.0 lib/runbook/generators/base.rb
runbook-0.14.0 lib/runbook/generators/base.rb
runbook-0.13.0 lib/runbook/generators/base.rb