init
parent
100883624b
commit
6dceece0e4
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
RUBDIR = "#{Dir.home}/.rub"
|
||||
|
||||
File.mkdir RUBDIR unless File.exist? RUBDIR
|
||||
FileUtils.cp("build.rb", RUBDIR)
|
||||
FileUtils.chmod("+x", "rub")
|
||||
FileUtils.cp("rub", "/usr/local/bin")
|
||||
@ -1,3 +1,57 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require "#{Dir.pwd}/build.rb"
|
||||
require 'fileutils'
|
||||
|
||||
ANSI_RED = "\e[31m"
|
||||
ANSI_CLEAR = "\e[0m"
|
||||
RUB = "#{ANSI_RED}RUB#{ANSI_CLEAR}"
|
||||
|
||||
RUBDIR = "#{Dir.home}/.rub/"
|
||||
|
||||
def error(msg)
|
||||
puts "#{RUB}: error: #{msg}"
|
||||
exit 1
|
||||
end
|
||||
|
||||
def message(msg)
|
||||
puts "#{RUB}: #{msg}"
|
||||
end
|
||||
|
||||
def rub_init(name)
|
||||
error("src directory already exists") if File.exist? "src"
|
||||
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)
|
||||
|
||||
`git init`
|
||||
`git branch -m main`
|
||||
end
|
||||
|
||||
def parse_arg(arg)
|
||||
case arg
|
||||
when "init"
|
||||
error("no project name provided")
|
||||
|
||||
when "meow"
|
||||
puts "#{RUB}: meow :3"
|
||||
end
|
||||
end
|
||||
|
||||
def parse_args(argv)
|
||||
case argv[0]
|
||||
when "init"
|
||||
rub_init(argv[1])
|
||||
end
|
||||
end
|
||||
|
||||
case ARGV.count
|
||||
when 0
|
||||
require "#{Dir.pwd}/build.rb"
|
||||
when 1
|
||||
parse_arg(ARGV[0])
|
||||
when 2
|
||||
parse_args(ARGV)
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue