78 lines
1.6 KiB
Text
78 lines
1.6 KiB
Text
|
#!/usr/bin/env ruby
|
||
|
|
||
|
require 'optparse'
|
||
|
require 'ostruct'
|
||
|
|
||
|
# dat set private git://repo
|
||
|
# dat init private
|
||
|
# dat install
|
||
|
# dat reinstall
|
||
|
|
||
|
options = OpenStruct.new
|
||
|
|
||
|
# take the first so OptionParser will not see it
|
||
|
subcommand = ARGV.shift&.to_sym
|
||
|
|
||
|
OptionParser.new do |opt|
|
||
|
opt.on('-i', '--install', 'Install dat for the user') { |o| options.type = :install }
|
||
|
opt.on('-u', '--update', 'Update') do |o|
|
||
|
options.type = :update
|
||
|
end
|
||
|
|
||
|
opt.on('-n', '--name NAME', 'Make the recipe') do |o|
|
||
|
options.name = o
|
||
|
end
|
||
|
|
||
|
opt.on('--cache', 'Use cache') do |o|
|
||
|
options.use_cache = true
|
||
|
end
|
||
|
|
||
|
opt.on('-t', '--target TARGET', ['user', 'usr', 'package', 'pkg', 'system', 'sys'], 'Target type (user, package, system)') do |target|
|
||
|
|
||
|
normalized = case target.downcase
|
||
|
when 'user', 'usr'
|
||
|
:user
|
||
|
when 'package', 'pkg'
|
||
|
:package
|
||
|
when 'system', 'sys'
|
||
|
:system
|
||
|
end
|
||
|
options.target = normalized
|
||
|
end
|
||
|
end.parse!
|
||
|
|
||
|
|
||
|
case subcommand
|
||
|
when :install
|
||
|
puts "installing...."
|
||
|
require 'install'
|
||
|
Install.base_install
|
||
|
when :update
|
||
|
puts "updating...."
|
||
|
require 'install'
|
||
|
Install.base_update
|
||
|
when :make
|
||
|
puts "making..."
|
||
|
require 'make'
|
||
|
Make.command(options)
|
||
|
when :goto
|
||
|
Dir.chdir(ENV["DAT_ROOT"])
|
||
|
when :vm
|
||
|
puts 'vm command'
|
||
|
# dat vm --create name
|
||
|
# dat vm --run name --graphic (default no graphic)
|
||
|
# Idea ===========
|
||
|
# dat vm --pool --execute script.sh
|
||
|
else
|
||
|
puts "Error not found #{options.type}"
|
||
|
end
|
||
|
|
||
|
# install locally for the user
|
||
|
# dat install
|
||
|
|
||
|
# dat set git://repo
|
||
|
# dat init
|
||
|
|
||
|
# dat deinit
|
||
|
# dat reinstall
|