-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils.go
More file actions
31 lines (26 loc) · 888 Bytes
/
utils.go
File metadata and controls
31 lines (26 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package utils contains commonly useful functions from Deisctl
package utils
import (
"fmt"
"os"
"strings"
)
// DeisIfy returns a pretty-printed deis logo along with the corresponding message
func DeisIfy(message string) string {
circle := "\033[31m●"
square := "\033[32m■"
triangle := "\033[34m▴"
reset := "\033[0m"
title := reset + message
return fmt.Sprintf("%s %s %s\n%s %s %s %s\n%s %s %s%s\n",
circle, triangle, square,
square, circle, triangle, title,
triangle, square, circle, reset)
}
// ResolvePath returns the path with a tilde (~) and $HOME replaced by the actual home directory
func ResolvePath(path string) string {
path = strings.Replace(path, "~", os.Getenv("HOME"), -1)
// Using $HOME seems to work just fine with `deisctl config`, but not `deisctl refresh-units`
path = strings.Replace(path, "$HOME", os.Getenv("HOME"), -1)
return path
}