# Class: YARD::CLI::Config

Inherits:
  Command
  - Object
  - Command
  - YARD::CLI::Config
  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

- #append ⇒ Boolean

  Whether to append values to existing key.

- #as_list ⇒ Boolean

  Whether the value being set should be inside a list.

- #gem_install_cmd ⇒ String?

  Command to use when configuring ~/.gemrc file.

- #key ⇒ Symbol?

  The key to view/edit, if any.

- #reset ⇒ Boolean

  Whether to reset the #key.

- #values ⇒ Array?

  The list of values to set (or single value), if modifying.

## Instance Method Summary collapse

- #description ⇒ Object
- #initialize ⇒ Config constructor

  A new instance of Config.

- #run(*args) ⇒ Object

## Constructor Details

### #initialize ⇒ `Config`

Returns a new instance of Config.

Since:

- 0.6.2

    26
    27
    28
    29
    30
    31
    32
    33
    34

    # File 'lib/yard/cli/config.rb', line 26

    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

### #append ⇒ `Boolean`

Returns whether to append values to existing key.

Returns:

- (`Boolean`) —

  whether to append values to existing key

Since:

- 0.6.2

    20
    21
    22

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

    def append
      @append
    end

### #as_list ⇒ `Boolean`

Returns whether the value being set should be inside a list.

Returns:

- (`Boolean`) —

  whether the value being set should be inside a list

Since:

- 0.6.2

    17
    18
    19

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

    def as_list
      @as_list
    end

### #gem_install_cmd ⇒ `String`?

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

Returns:

- (`String`, `nil`) —

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

Since:

- 0.6.2

    24
    25
    26

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

    def gem_install_cmd
      @gem_install_cmd
    end

### #key ⇒ `Symbol`?

Returns the key to view/edit, if any.

Returns:

- (`Symbol`, `nil`) —

  the key to view/edit, if any

Since:

- 0.6.2

    8
    9
    10

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

    def key
      @key
    end

### #reset ⇒ `Boolean`

Returns whether to reset the #key.

Returns:

- (`Boolean`) —

  whether to reset the #key

Since:

- 0.6.2

    14
    15
    16

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

    def reset
      @reset
    end

### #values ⇒ `Array`?

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

Returns:

- (`Array`, `nil`) —

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

Since:

- 0.6.2

    11
    12
    13

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

    def values
      @values
    end

## Instance Method Details

### #description ⇒ `Object`

Since:

- 0.6.2

    36
    37
    38

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

    def description
      'Views or edits current global configuration'
    end

### #run(*args) ⇒ `Object`

Since:

- 0.6.2

    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53

    # File 'lib/yard/cli/config.rb', line 40

    def run(*args)
      optparse(*args)
      if gem_install_cmd
        configure_gemrc
      elsif key
        if reset || !values.empty?
          modify_item
        else
          view_item
        end
      else
        list_configuration
      end
    end