Class: Do::ConfigCommand

Inherits:
Thor
  • Object
show all
Defined in:
lib/do/cli.rb

Overview

do config path / do config show.

Instance Method Summary collapse

Instance Method Details

#pathObject



20
21
22
# File 'lib/do/cli.rb', line 20

def path
  say ENV['DO_CONFIG'] || Do::Config.default_path
end

#showObject

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/do/cli.rb', line 25

def show
  cfg_path = ENV['DO_CONFIG'] || Do::Config.default_path
  raise Do::Error, "Configuration file does not exist: #{cfg_path}" unless File.exist?(cfg_path)

  config = Do::Config.load(cfg_path)
  errors = Do::Validator.validate(config)
  unless errors.empty?
    errors.each { |e| say "Error: #{e}", :red }
    exit(1)
  end
  say "path: #{cfg_path}"
  say 'tasks:'
  config.tasks.each do |task|
    say "  #{task.name}:"
    say "    command:          #{task.command}"
    say "    schedule:         #{task.schedule || 'manual'}"
    say "    time:             #{task.time || '-'}"
    say "    day:              #{task.day || '-'}"
    say "    working_directory: #{task.working_directory || '-'}"
    say "    enabled:          #{task.enabled?}"
    say "    environment:      #{task.environment.inspect}" unless (task.environment || {}).empty?
  end
end