diff --git a/build.rb b/build.rb index 506fef1..a727bd2 100755 --- a/build.rb +++ b/build.rb @@ -31,13 +31,16 @@ def parse(arg) when "debug" $EFLAGS = "-DDEBUG" main + + else + #error "unknown argument: #{arg}" + print arg + end - when arg.split("=")[0] = "cc" + case arg.split("=")[0] + when "cc" $CC = arg.split("=")[1] main - - else - error "unknown argument: #{arg}" end end diff --git a/rub b/rub index 8151aad..a1eaf9f 100755 --- a/rub +++ b/rub @@ -2,6 +2,11 @@ require 'fileutils' +HELP = "\trub init - initialize a new project\n" \ + "\trub help - display help message\n" \ + "\trub meow - meows\n" \ + "\trub - run build.rb in current directory\n" + ANSI_RED = "\e[31m" ANSI_CLEAR = "\e[0m" RUB = "#{ANSI_RED}RUB#{ANSI_CLEAR}" @@ -22,9 +27,13 @@ def rub_init(name) error("build directory already exists") if File.exist? "build" error(".git already exists") if File.exist? ".git" - File.mkdir "src" - File.mkdir "build" - FileUtils.cp(RUBDIR + "build.rb", Dir.pwd) + FileUtils.mkdir "src" + FileUtils.mkdir "build" + #FileUtils.cp(RUBDIR + "build.rb", Dir.pwd) + + buildfile = File.readlines(RUBDIR + "build.rb") + buildfile.insert(17, "APPNAME=\"#{name}\"\n") + File.write("build.rb", buildfile.join) `git init` `git branch -m main` @@ -37,6 +46,10 @@ def parse_arg(arg) when "meow" puts "#{RUB}: meow :3" + + when "help" + puts HELP + end end @@ -49,9 +62,16 @@ end case ARGV.count when 0 + unless File.exist? "build.rb" + error("could not find 'build.rb'") + end + require "#{Dir.pwd}/build.rb" + exit 0 when 1 parse_arg(ARGV[0]) when 2 parse_args(ARGV) end + +#require "#{Dir.pwd}/build.rb"