Class: Rubygb::CLI

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

Instance Method Summary collapse

Instance Method Details

#build(filename) ⇒ Object



8
9
10
# File 'lib/rubygb/cli.rb', line 8

def build filename
  Rubygb.build filename, options
end

#init(project_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rubygb/cli.rb', line 13

def init project_name
  puts "Creating new project at #{File.expand_path project_name}"
  raise "Project already exists at #{File.expand_path project_name}!"if Dir.exists? project_name

  Dir.mkdir project_name
  galp_dest = File.join(project_name,"lib")
  Dir.mkdir galp_dest
  galp_lib = File.expand_path(File.join(File.dirname(__FILE__),"..","galp"))

  Dir.glob(File.join(galp_lib,"*")) do |file|
    puts "Copying #{File.basename(file)}..."
    FileUtils.copy file, galp_dest
  end

  template = Template.basic(project_name)
  filename = File.join(project_name,"#{project_name}.s")
  puts "Generating #{filename}..."
  File.open(filename,"w") {|f| f << template}

  puts "Done!"
end