Class: Cliqr::Config::Shell Private

Inherits:
OptionBased show all
Defined in:
lib/cliqr/config/shell.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Config attributes for shell

Instance Attribute Summary collapse

Attributes inherited from OptionBased

#options

Attributes inherited from Named

#description, #name

Attributes inherited from EventBased

#events

Instance Method Summary collapse

Methods inherited from OptionBased

#option, #option?, #options?, #set_config

Methods inherited from Named

#description?, #name?

Methods inherited from EventBased

#event, #handle?, #set_config

Methods inherited from Base

#set_config, #skip_validation?

Methods included from Validation

#errors, included, #read_attributes, #valid?, #validate, #validations

Methods included from DSL

included

Constructor Details

#initializeShell

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new config instance for an option with UNSET attribute values



43
44
45
46
47
48
49
# File 'lib/cliqr/config/shell.rb', line 43

def initialize
  super

  @enabled = UNSET
  @prompt = UNSET
  @banner = UNSET
end

Instance Attribute Details

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Banner that is displayed when shell starts

Returns:

  • (String)


34
35
36
# File 'lib/cliqr/config/shell.rb', line 34

def banner
  @banner
end

#enabledSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enable or disable the shell action

Returns:

  • (Symbol)


15
16
17
# File 'lib/cliqr/config/shell.rb', line 15

def enabled
  @enabled
end

#promptString, Proc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Prompt for the shell

Returns:

  • (String)
  • (Proc)


23
24
25
# File 'lib/cliqr/config/shell.rb', line 23

def prompt
  @prompt
end

Instance Method Details

#disable_colorCliqr::Command::Color

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Disable colors in shell



82
83
84
# File 'lib/cliqr/config/shell.rb', line 82

def disable_color
  @prompt.disable_color if @prompt.respond_to?(:disable_color)
end

#enabled?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if shell is enabled

Returns:

  • (Boolean)


75
76
77
# File 'lib/cliqr/config/shell.rb', line 75

def enabled?
  @enabled
end

#finalizeCliqr::Config::Option

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Finalize shell’s config by adding default values for unset values



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cliqr/config/shell.rb', line 54

def finalize
  super

  case @enabled
  when Cliqr::Config::ENABLE_CONFIG
    @enabled = true
  when Cliqr::Config::DISABLE_CONFIG
    @enabled = false
  when UNSET
    @enabled = true
  end
  @prompt = Config.get_if_unset(@prompt, Cliqr::Command::ShellPromptBuilder.new)
  @banner = Config.get_if_unset(@banner, Cliqr::Command::ShellBannerBuilder.new)

  # set default name for the shell action
  @name = 'shell' if @name.is_a?(String) && @name.empty?

  self
end