Class: RComp::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



8
9
10
11
12
# File 'lib/rcomp/cli.rb', line 8

def initialize(args=[], options={}, config={})
  super
  # load Conf singleton
  @conf = Conf.instance
end

Instance Method Details

#generateObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rcomp/cli.rb', line 64

def generate
  Env.guard_uninitialized

  # Display confirmation dialouge when -O is passed without filter
  if !@options[:grep] && options.overwrite
    unless yes? "This will overwrite all existing expected results."
      say 'Aborting...'
      exit 1
    end
  end

  if @options[:grep]
    Runner.run(Suite.load(@options[:grep]), :generate, @options)
  else
    Runner.run(Suite.load, :generate, @options)
  end
end

#initObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/rcomp/cli.rb', line 19

def init
  Env.guard_initialized

  unless Env.command_exists?
    @conf.set_command(ask("Enter the command you want to test:"))
  end

  Env.initialize_directories
  puts "RComp successfully initialized"
end

#testObject



43
44
45
46
47
48
49
50
# File 'lib/rcomp/cli.rb', line 43

def test
  Env.guard_uninitialized
  if @options[:grep]
    Runner.run(Suite.load(@options[:grep]), :test)
  else
    Runner.run(Suite.load, :test)
  end
end

#versionObject



32
33
34
# File 'lib/rcomp/cli.rb', line 32

def version
  puts "RComp version #{RComp::VERSION}"
end