2016-11-01 09:56:12 +00:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Settings) Wdir() string {
|
|
|
|
dir, err := os.Getwd()
|
|
|
|
s.Validate(err)
|
|
|
|
return filepath.Base(dir)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s Settings) Validate(err error) error {
|
|
|
|
if err != nil {
|
2016-12-16 22:53:27 +00:00
|
|
|
s.Fatal(err, "")
|
2016-11-01 09:56:12 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-12-16 22:53:27 +00:00
|
|
|
func (s Settings) Fatal(err error, msg ...interface{}) {
|
|
|
|
if len(msg) > 0 {
|
|
|
|
log.Fatalln(s.Red.Regular(msg...), err.Error())
|
2016-11-01 09:56:12 +00:00
|
|
|
}
|
2016-12-16 22:53:27 +00:00
|
|
|
log.Fatalln(err.Error())
|
2016-11-01 09:56:12 +00:00
|
|
|
}
|