Sha256: 40a3ea3a0d27f9a2715c9657a2134a73c31ae71f517c5119dca30d00b7cfba60

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'thor'
require 'fileutils'

module Rubygb
  class CLI < Thor
    desc 'build FILENAME', 'attempt to assemble, link + fix FILENAME and create a gb rom from it'
    option :no_fix, type: :boolean, desc: 'skip header fixing'
    option :output, desc: 'dir to put all build files'
    def build filename
      Rubygb.build filename, options
    end

    desc 'init PROJECT_NAME', 'create a new gameboy project at the location'
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubygb-0.2.2 lib/rubygb/cli.rb