Sha256: 0e62962d9d7cc27906a659e4cb4afa6dc9692cbcdcb4664dfa168ada09e73368

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 Bytes

Contents

require 'cliprompt'
require 'configstruct'
require 'fileutils'

module Shellplay
  class Config < ConfigStruct

    include Cliprompt

    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

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

    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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shellplay-0.0.12 lib/shellplay/config.rb
shellplay-0.0.11 lib/shellplay/config.rb
shellplay-0.0.10 lib/shellplay/config.rb
shellplay-0.0.9 lib/shellplay/config.rb