Class: Shellplay::Config

Inherits:
ConfigStruct
  • Object
show all
Includes:
Cliprompt
Defined in:
lib/shellplay/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = nil, input = STDIN, output = STDOUT) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
# File 'lib/shellplay/config.rb', line 9

def initialize(options = nil, input = STDIN, output = STDOUT)
  confdir = File.join(ENV['HOME'], '.shellplay')
  FileUtils.mkdir_p confdir unless Dir.exist? confdir
  super(options = nil, input = STDIN, output = STDOUT)
end

Instance Method Details

#set_defaultsObject



15
16
17
18
# File 'lib/shellplay/config.rb', line 15

def set_defaults
  default :basedir, File.join(ENV['HOME'], '.shellplay')
  super
end

#setupObject



20
21
22
23
24
25
26
27
# File 'lib/shellplay/config.rb', line 20

def setup
  values = {}
  output.puts Paint['Create a new shellplay configuration:', :blue]
  values['editor'] = guess 'EDITOR', 'What is the path to launch your text editor?', 'vim'
  values['prompt'] = ask 'What is the default prompt you want to use?'
  values['timeformat'] = ask 'What is the time format you want to display?', '%.1f'
  write values
end