Sha256: 30d0134ff02ddf5ed8ea4fe47b33d16547e721c51e34acdf7be490e5bc2a11fe

Contents?: true

Size: 909 Bytes

Versions: 7

Compression:

Stored size: 909 Bytes

Contents

#! /usr/bin/env ruby

require 'json'
require 'qless'
require 'thor'

class Configurator < Thor

  class_option :redis, :default => 'redis://localhost:6379/0'

  no_commands do
    def qless
      if @qless.nil?
        @qless = Qless::Client.new(url: options[:redis])
      end
      @qless
    end
  end

  desc 'dump', 'Get config and print to stdout'
  def dump
    puts JSON.pretty_generate(qless.config.all)
  end

  desc 'load <filename> [--clear]', 'Set config from a file and command-line args'
  option :clear, :type => :boolean, :default => false
  def load(filename)
    File.open(filename) do |file|
      values = JSON.load(file)

      if options[:clear]
        (qless.config.all.keys - values.keys).each do |key|
          qless.config.clear(key)
        end
      end

      values.each do |key, value|
        qless.config[key] = value
      end
    end
  end

end

Configurator.start(ARGV)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
qless-0.12.0 exe/qless-config
qless-0.11.0 exe/qless-config
qless-0.10.5 exe/qless-config
qless-0.10.4 exe/qless-config
qless-0.10.3 exe/qless-config
qless-0.10.2 exe/qless-config
qless-0.10.1 exe/qless-config