github.com/SupersunnySea/draft@v0.16.0/pkg/draft/draftpath/home.go (about) 1 package draftpath 2 3 import ( 4 "path/filepath" 5 ) 6 7 // Home describes the location of a CLI configuration. 8 // 9 // This helper builds paths relative to a Draft Home directory. 10 type Home string 11 12 // Path returns Home with elements appended. 13 func (h Home) Path(elem ...string) string { 14 p := []string{h.String()} 15 p = append(p, elem...) 16 return filepath.Join(p...) 17 } 18 19 // Config returns the path to the Draft config file. 20 func (h Home) Config() string { 21 return h.Path("config.toml") 22 } 23 24 // Packs returns the path to the Draft starter packs. 25 func (h Home) Packs() string { 26 return h.Path("packs") 27 } 28 29 // Logs returns the path to the Draft logs. 30 func (h Home) Logs() string { 31 return h.Path("logs") 32 } 33 34 // Plugins returns the path to the Draft plugins. 35 func (h Home) Plugins() string { 36 return h.Path("plugins") 37 } 38 39 // String returns Home as a string. 40 // 41 // Implements fmt.Stringer. 42 func (h Home) String() string { 43 return string(h) 44 }