-
-
Save zackp30/6374d13ee1f88948c833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'thor' | |
require 'yaml' | |
require 'parseconfig' | |
module DBY | |
class DBYConfig | |
# Parse configuration. | |
def parse | |
@confloc = "#{Dir.home}/.dby.conf" | |
@dbyconfig = ParseConfig.new(@confloc) | |
end | |
def init_conf | |
if File.size(@confloc) > 0 | |
@dbyconfig = ParseConfig.new(@confloc) | |
else | |
# Create initial config file. | |
File.open("#{@confloc}", 'w+') { |f| | |
f.write(" | |
[repos] | |
zack = http://zackp30.tk/stuff/repos | |
") | |
f.close | |
} | |
end | |
end | |
DBY::DBYConfig.parse | |
DBY::DBYConfig.init_conf | |
end | |
#init_file = YAML.load_file "#{Dir.getwd}/.init.yaml" unless File.exists?("#{Dir.getwd}") | |
class Repo < Thor | |
desc 'add', 'Add a new repo.' | |
def add(name, url) | |
DBYConfig.parse | |
puts "#{@confloc}" | |
#puts @dbyconfig.get_groups | |
#if File.size("#{@confloc}") > 0 | |
##@dbyconfig['repos']["#{name}"] = "#{url}" | |
##@dbyconfig.write(@conffile) | |
##@conffile.close | |
#puts "pls" | |
#else | |
#puts "You do not have a config file." | |
#end | |
end | |
end | |
class Package < Thor | |
desc 'install', 'Install a package.' | |
def install | |
puts "Todo: Implement this." | |
end | |
end | |
class CLI < Thor | |
desc 'package', 'Package management.' | |
subcommand "package", Package | |
desc 'repo', 'Repo management.' | |
subcommand "repo", Repo | |
end | |
end | |
DBY::CLI.start(ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment