fubarhouse / dvm

Drush version manager (DVM)
http://fubarhouse.github.io/dvm/
4 stars 2 forks source link

Ability to specify the path for the symlink... #90

Closed fubarhouse closed 7 years ago

fubarhouse commented 7 years ago

Perhaps a more traditional flag with associated documentation to write/rewrite a config file for the location - with a default location?

fubarhouse commented 7 years ago

Best way forward for this would be to parse/encode a toml file at the .dvm directory...

fubarhouse commented 7 years ago
[dvm]
name = "Drush Version Manager"
path = "/usr/local/bin/drush"
package conf

import (
    "os"
    "os/user"
    "github.com/naoina/toml"
)

type config struct {
    Dvm struct {
        Name string
        Path string
    }
}

func getSettings() *config {
    x, _ := user.Current()
    y := x.HomeDir
    cp := y + "/.dvm/config.toml"

    println(cp)
    f, err := os.Open(cp)
    if err != nil {
        panic(err)
    }
    defer f.Close()
    var c config
    if err := toml.NewDecoder(f).Decode(&c); err != nil {
        panic(err)
    }
    return &c;
}

func Path() string {
    c := getSettings()
    return c.Dvm.Path
}

func Set(name, value string) {
    getSettings()
}