Bläddra i källkod

add helper to parse host based config dir

pull/36/head
Rob Loranger 5 år sedan
förälder
incheckning
834bc2a440
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: D6F1633A4F0903B8
1 ändrade filer med 15 tillägg och 0 borttagningar
  1. +15
    -0
      config/options.go

+ 15
- 0
config/options.go Visa fil

@@ -1,6 +1,8 @@
package config

import (
"net/url"

"github.com/cloudfoundry/jibber_jabber"
"github.com/writeas/writeas-cli/log"
cli "gopkg.in/urfave/cli.v1"
@@ -54,3 +56,16 @@ func Collection(c *cli.Context) string {
}
return ""
}

// HostDirectory returns the sub directory string for the host flag if set
func HostDirectory(c *cli.Context) (string, error) {
if host := c.GlobalString("host"); host != "" {
u, err := url.Parse(host)
if err != nil {
return "", err // TODO
}
return u.Hostname(), nil
}

return "", nil
}

Laddar…
Avbryt
Spara