forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.go
More file actions
44 lines (36 loc) · 612 Bytes
/
Copy pathenv.go
File metadata and controls
44 lines (36 loc) · 612 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
32
33
34
35
36
37
38
39
40
41
42
43
44
package cmd
import (
"context"
"fmt"
"github.com/railwayapp/cli/entity"
)
func Min(x, y int) int {
if x < y {
return x
}
return y
}
func Max(x, y int) int {
if x > y {
return x
}
return y
}
func (h *Handler) Env(ctx context.Context, req *entity.CommandRequest) error {
envs, err := h.ctrl.GetEnvs(ctx)
if err != nil {
return err
}
var minSpacing = 15
var maxSpacing = 100
var longest = 0
for k := range *envs {
if len(k) > longest {
longest = len(k)
}
}
for k, v := range *envs {
fmt.Printf("%-*s\t%s\n", Max(minSpacing, Min(maxSpacing, longest)), k, v)
}
return nil
}