Class: Inch::CLI::Command::Options::Base

Inherits:
Object
  • Object
show all
Includes:
TraceHelper, YardoptsHelper
Defined in:
lib/inch/cli/command/options/base.rb

Overview

Abstract base class for CLI options. Provides some helper methods for the option parser

Direct Known Subclasses

BaseList, BaseObject

Constant Summary

Constants included from YardoptsHelper

YardoptsHelper::VALID_YARD_SWITCHES

Instance Attribute Summary

Attributes included from YardoptsHelper

#excluded, #yard_files

Class Method Summary collapse

Instance Method Summary collapse

Methods included from YardoptsHelper

#parse_yardopts_options, #yardopts_options

Methods included from TraceHelper

#debug, #trace, #trace_header

Class Method Details

.attribute(name, default = nil) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/inch/cli/command/options/base.rb', line 15

def attribute(name, default = nil)
  define_method(name) do
    instance_variable_get("@#{name}") || default
  end
  define_method("#{name}=") do |value|
    instance_variable_set("@#{name}", value)
  end
end

Instance Method Details

#parse(args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/inch/cli/command/options/base.rb', line 29

def parse(args)
  opts = OptionParser.new
  opts.banner = usage

  descriptions.each do |text|
    opts.separator "  " + text
  end

  set_options(opts)
  parse_options(opts, args)
end

#set_options(opts) ⇒ Object



41
42
43
# File 'lib/inch/cli/command/options/base.rb', line 41

def set_options(opts)
  common_options(opts)
end

#verifyObject

Override and fill with validations



46
47
# File 'lib/inch/cli/command/options/base.rb', line 46

def verify
end