Class: Skeletor::CLI

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

Overview

The CLI class provides an interface for the command line functions

Instance Method Summary collapse

Instance Method Details

#build(template) ⇒ Object

Creates a new Builder instance and builds the skeleton in the specified directory



18
19
20
21
22
23
24
# File 'lib/skeletor/cli.rb', line 18

def build(template)
  path = options[:directory] || Dir.pwd
  project = options[:project] || File.basename(path)
  
  skeleton = Builder.new(project,template,path)
  skeleton.build
end

#cleanObject

Cleans out the specified directory



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/skeletor/cli.rb', line 32

def clean
  print 'Are you sure you want to clean this project directory? (Y|n): '
  confirm = $stdin.gets.chomp
  if confirm != 'Y' && confirm != 'n'
    puts 'Please enter Y or n'
  elsif confirm == 'Y'
    path = options[:directory] || Dir.pwd
    Builder.clean path
  end
  
end

#validate(template) ⇒ Object

Loads a template, creates a new Validator and validates the template



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/skeletor/cli.rb', line 46

def validate(template)
  skeleton = Skeletons::Loader.load_template(template)
  validator = Grayskull::Validator.new(skeleton,Skeletons::Skeleton::SCHEMA_FILE)
  results = validator.validate
  
   if !results['result']
    puts 'Validation Failed with ' + @errors.count.to_s + ' errors';
        puts ''
        results["errors"].each{
          |error|
          puts error            
        }
  else
    puts 'Validated Successfully!'
  end
end