Fix broken --cfg flag

This commit is contained in:
Jakob Borg 2014-01-01 08:49:55 -05:00
parent 1c4e710adc
commit 232d715c37
1 changed files with 7 additions and 12 deletions

19
main.go
View File

@ -66,11 +66,6 @@ var (
nodeAddrs = make(map[string][]string) nodeAddrs = make(map[string][]string)
) )
// Options
var (
ConfDir = path.Join(getHomeDir(), confDirName)
)
func main() { func main() {
_, err := flags.Parse(&opts) _, err := flags.Parse(&opts)
if err != nil { if err != nil {
@ -87,11 +82,11 @@ func main() {
// Ensure that our home directory exists and that we have a certificate and key. // Ensure that our home directory exists and that we have a certificate and key.
ensureDir(ConfDir, 0700) ensureDir(opts.ConfDir, 0700)
cert, err := loadCert(ConfDir) cert, err := loadCert(opts.ConfDir)
if err != nil { if err != nil {
newCertificate(ConfDir) newCertificate(opts.ConfDir)
cert, err = loadCert(ConfDir) cert, err = loadCert(opts.ConfDir)
fatalErr(err) fatalErr(err)
} }
@ -120,7 +115,7 @@ func main() {
// Load the configuration file, if it exists. // Load the configuration file, if it exists.
cf, err := os.Open(path.Join(ConfDir, confFileName)) cf, err := os.Open(path.Join(opts.ConfDir, confFileName))
if err != nil { if err != nil {
fatalln("No config file") fatalln("No config file")
config = ini.Config{} config = ini.Config{}
@ -301,7 +296,7 @@ func updateLocalModel(m *Model) {
func saveIndex(m *Model) { func saveIndex(m *Model) {
name := fmt.Sprintf("%x.idx", sha1.Sum([]byte(m.Dir()))) name := fmt.Sprintf("%x.idx", sha1.Sum([]byte(m.Dir())))
fullName := path.Join(ConfDir, name) fullName := path.Join(opts.ConfDir, name)
idxf, err := os.Create(fullName + ".tmp") idxf, err := os.Create(fullName + ".tmp")
if err != nil { if err != nil {
return return
@ -313,7 +308,7 @@ func saveIndex(m *Model) {
func loadIndex(m *Model) { func loadIndex(m *Model) {
fname := fmt.Sprintf("%x.idx", sha1.Sum([]byte(m.Dir()))) fname := fmt.Sprintf("%x.idx", sha1.Sum([]byte(m.Dir())))
idxf, err := os.Open(path.Join(ConfDir, fname)) idxf, err := os.Open(path.Join(opts.ConfDir, fname))
if err != nil { if err != nil {
return return
} }