Class: Rubex::Cli

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

Overview

Cli for rubex using Thor(whatisthor.com/)

Instance Method Summary collapse

Instance Method Details

#generate(file) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubex/cli.rb', line 13

def generate(file)
  if (force = options[:force])
    directory = (options[:dir] ? options[:dir].to_s : Dir.pwd) +
                "/#{Rubex::Compiler.extract_target_name(file)}"
    STDOUT.puts "Warning! you are about to replace contents in the directory '#{directory}', Are you sure? [Yn] "
    confirmation = STDIN.gets.chomp
    force = (confirmation == 'Y')
  end
  Rubex::Compiler.compile file, target_dir: options[:dir], force: force,
                          make: options[:install], debug: options[:debug]
end

#install(path) ⇒ Object



27
28
29
# File 'lib/rubex/cli.rb', line 27

def install(path)
  Rubex::Compiler.run_make path
end