Sha256: 132649ea14f5ea3215f0d9dd77658ab6056d54df675b52ad7cda874c5de541e2
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
#!/usr/bin/env ruby require "thor" require "redis" require "dotenv" require "redis_env" class CLI < Thor class_option :project, type: :string, desc: "The project these variables are for" class_option :redis, type: :string, desc: "The url of the redis server", default: "redis://localhost:6379/0" desc "set NAME VALUE", "Set an environment variable called NAME to VALUE" def set(name, value) client.set(name, value) end desc "load FILE", "Read an env file and load it into redis" def load(file) vars = Dotenv::Environment.new(file) client.bulk_set(vars) end desc "unset NAME", "Remove an environment variable called NAME" def unset(name) client.unset(name) end desc "clear", "Remove all environment variables" def clear client.clear end desc "list", "List all variables" def list width = env.keys.map(&:length).max env.sort_by(&:first).each do |k, v| puts [k.ljust(width), v].join("\t") end end desc "exec COMMAND", "Run a COMMAND within the environment" def exec(*command) super(env, command.join(" ")) end private def client @client ||= RedisEnv.new(Redis.new(url: options[:redis]), options[:project]) end def env @env ||= client.variables end end CLI.start(ARGV)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis_env-0.2.0 | exe/redis-env |