Class: ENVied::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/envied/cli.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



73
74
75
76
77
78
# File 'lib/envied/cli.rb', line 73

def check
  ENVied.require(*options[:groups])
  unless options[:quiet]
    puts "All variables for group(s) #{options[:groups]} are present and valid"
  end
end

#extractObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/envied/cli.rb', line 25

def extract
  globs = options[:globs]
  globs << "{test,spec}/*" if options[:tests]
  var_occurences = ENVied::EnvVarExtractor.new(globs: globs).extract

  puts "Found %d occurrences of %d variables:" % [var_occurences.values.flatten.size, var_occurences.size]
  var_occurences.sort.each do |var, occs|
    puts var
    occs.sort_by{|i| i[:path].size }.each do |occ|
      puts "* %s:%s" % occ.values_at(:path, :line)
    end
    puts
  end
end

#initObject



41
42
43
44
45
46
47
48
49
# File 'lib/envied/cli.rb', line 41

def init
  puts "Writing Envfile to #{File.expand_path('Envfile')}"
  template("Envfile.tt")

  puts <<-INIT
Add the following snippet (or similar) to your app's initialization:
ENVied.require(*ENV['ENVIED_GROUPS'] || [:default, ENV['RACK_ENV']])
INIT
end

#versionObject



10
11
12
# File 'lib/envied/cli.rb', line 10

def version
  puts ENVied::VERSION
end