Sha256: 1e9b7a3f0742bfc3cbbb529df546dc803ed6f6aa612fa3c77880ce1bde90c626

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 KB

Contents

module Relish
  module Command
    class Config < Base

      class Option
        VALID_OPTIONS = %w(project)

        def initialize(param)
          @option, @value = param.split(':')
          validate_option
        end

        def validate_option
          unless VALID_OPTIONS.include?(@option)
            Relish::Helpers.error "'#{@option}' is not a valid option." +
                                  " Valid options: #{VALID_OPTIONS.join(', ')}"
          end
        end

        def to_hash
          {@option => @value}
        end
      end

      desc    'display the contents of your options file'
      command :default do
        puts(if File.exists?(Relish.local_options_file)
          IO.read(Relish.local_options_file)
        else
          "No #{Relish.local_options_file} file exists"
        end)
      end

      usage   'config:add <option>:<value>'
      desc    'add a configuration option to your options file',
              'example: relish config:add project:rspec-core',
              "valid configuration options: #{Option::VALID_OPTIONS.join(', ')}"
      command :add do
        option = Option.new(@param)
        OptionsFile.new(Relish.local_options_file).store(option.to_hash)
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
relish-0.7.1 lib/relish/commands/config.rb
relish-0.7 lib/relish/commands/config.rb
relish-0.6 lib/relish/commands/config.rb
relish-0.5.3 lib/relish/commands/config.rb
relish-0.5.2 lib/relish/commands/config.rb
relish-0.5.1 lib/relish/commands/config.rb
relish-0.5.0 lib/relish/commands/config.rb
relish-0.4.0 lib/relish/commands/config.rb
relish-0.3.0 lib/relish/commands/config.rb
relish-0.3.0.pre lib/relish/commands/config.rb
relish-0.2.3 lib/relish/commands/config.rb
relish-0.2.2 lib/relish/commands/config.rb
relish-0.2.1 lib/relish/commands/config.rb