Module: Lxc::Helpers::Options

Included in:
Clone, Ephemeral
Defined in:
lib/elecksee/helpers/options.rb

Overview

Helper methods for processing CLI options

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ TrueClass

Load option helper into included class

Parameters:

  • klass (Class)

Returns:

  • (TrueClass)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/elecksee/helpers/options.rb', line 12

def included(klass)
  klass.class_eval do
    class << self

      # @return [Hash] options
      attr_reader :options

      # Define option
      #
      # @param name [String] name of option
      # @param short [String] short flag
      # @param long [String] long flag
      # @param args [Hash]
      def option(name, short, type, args={})
        @options ||= {}
        @options[name] = args.merge(:short => short, :type => type)
        instance_eval do
          attr_accessor name.to_sym
        end
      end
    end
  end
end