Class: YARD::CLI::Config

Inherits:
Command show all
Defined in:
lib/yard/cli/config.rb

Overview

CLI command to view or edit configuration options

Since:

  • 0.6.2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config

Since:

  • 0.6.2


25
26
27
28
29
30
31
32
33
# File 'lib/yard/cli/config.rb', line 25

def initialize
  super
  self.key = nil
  self.values = []
  self.reset = false
  self.append = false
  self.as_list = false
  self.gem_install_cmd = nil
end

Instance Attribute Details

#appendBoolean

Returns whether to append values to existing key

Since:

  • 0.6.2


19
20
21
# File 'lib/yard/cli/config.rb', line 19

def append
  @append
end

#as_listBoolean

Returns whether the value being set should be inside a list

Since:

  • 0.6.2


16
17
18
# File 'lib/yard/cli/config.rb', line 16

def as_list
  @as_list
end

#gem_install_cmdString?

Returns command to use when configuring ~/.gemrc file. If the string is nil, configuration should not occur.

Since:

  • 0.6.2


23
24
25
# File 'lib/yard/cli/config.rb', line 23

def gem_install_cmd
  @gem_install_cmd
end

#keySymbol?

Returns the key to view/edit, if any

Since:

  • 0.6.2


7
8
9
# File 'lib/yard/cli/config.rb', line 7

def key
  @key
end

#resetBoolean

Returns whether to reset the #key

Since:

  • 0.6.2


13
14
15
# File 'lib/yard/cli/config.rb', line 13

def reset
  @reset
end

#valuesArray?

Returns the list of values to set (or single value), if modifying

Since:

  • 0.6.2


10
11
12
# File 'lib/yard/cli/config.rb', line 10

def values
  @values
end

Instance Method Details

#descriptionObject

Since:

  • 0.6.2


35
36
37
# File 'lib/yard/cli/config.rb', line 35

def description
  'Views or edits current global configuration'
end

#run(*args) ⇒ Object

Since:

  • 0.6.2


39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/yard/cli/config.rb', line 39

def run(*args)
  optparse(*args)
  if gem_install_cmd
    configure_gemrc
  elsif key
    if reset || values.size > 0
      modify_item
    else
      view_item
    end
  else
    list_configuration
  end
end