A config file location option

This commit is contained in:
Jack L. Frost 2016-09-29 16:01:35 +03:00
parent fcc9550fd5
commit 64e1442d93
1 changed files with 15 additions and 12 deletions

View File

@ -61,12 +61,6 @@ class DoSystem < Worker
end
end
class ::String
def erb
return ERB.new(self).result
end
end
module Modules
@modules = {}
@ -88,7 +82,7 @@ class Template
@config = config
@panel_data = data
return ERB.new(@template).result(binding)
return ERB.new(@template).result(binding())
end
end
@ -107,9 +101,19 @@ end
require 'erb'
require 'yaml'
require 'optparse'
workers = []
panel_data = {}
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: moltenvar [-c]"
opts.on("-cCONFIG", "--config=CONFIG") do |v|
options[:config_file] = v
end
end.parse!
if ENV["XDG_CONFIG_HOME"] == nil
conf_dir = ENV["HOME"] + "/.config/moltenbar"
@ -117,15 +121,14 @@ else
conf_dir = ENV["XDG_CONFIG_HOME"] + "/moltenbar"
end
config_file = conf_dir + "/rc.yaml"
mod_dir = conf_dir + "/mod"
options[:config_file] ||= conf_dir + "/rc.yaml"
puts config_file
config = YAML.load_file(options[:config_file])
config = YAML.load_file(config_file)
config['mod_dir'] ||= conf_dir + "/mod"
for m in config['modules'] do
load("#{mod_dir}/#{m}")
load("#{config['mod_dir']}/#{m}")
end
pipe_r, pipe_w = IO.pipe