class Dustcart::CLI

command facade

Public Instance Methods

exec() click to toggle source
# File lib/dustcart/cli.rb, line 11
def exec
  instruction_file = (options[:instruction_file] || "#{Dir.home}/.dustcart/default.rb")

  begin
    check_file(instruction_file)
  rescue => error
    puts "ERROR: #{error.message}"
    exit 1
  end

  dsl = DSL.new
  dsl.load(instruction_file)
end
version() click to toggle source
# File lib/dustcart/cli.rb, line 26
def version
  puts Dustcart::VERSION
end

Private Instance Methods

check_file(file) click to toggle source
# File lib/dustcart/cli.rb, line 32
    def check_file(file)
      raise <<-EOS.unindent unless File.exist?(file)
        The instruction file (#{file}) doesn't exists.
      EOS

      mode = format('%o', File.stat(file).mode)[-3, 3]

      raise <<-EOS.unindent unless mode == '600'
        The instruction file (#{file}) has too open permission.
        Make sure its permission is 600.
      EOS
    end