This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
account_features.go
133 lines (112 loc) · 2.78 KB
/
account_features.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package main
import (
"fmt"
"io"
"log"
"os"
"text/tabwriter"
"github.com/heroku/hk/Godeps/_workspace/src/github.com/bgentry/heroku-go"
)
var cmdAccountFeatures = &Command{
Run: runAccountFeatures,
Usage: "account-features",
Category: "account",
Short: "list account features" + extra,
Long: `
Account-features lists Heroku Labs features for your account.
Example:
$ hk account-features
+ pipelines
`,
}
func runAccountFeatures(cmd *Command, args []string) {
if len(args) != 0 {
cmd.PrintUsage()
os.Exit(2)
}
w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0)
defer w.Flush()
features, err := client.AccountFeatureList(&heroku.ListRange{Field: "name"})
must(err)
listAccountFeatures(w, features)
}
func listAccountFeatures(w io.Writer, features []heroku.AccountFeature) {
for _, f := range features {
enabled := " "
if f.Enabled {
enabled = "+"
}
listRec(w,
enabled,
f.Name,
)
}
}
var cmdAccountFeatureInfo = &Command{
Run: runAccountFeatureInfo,
Usage: "account-feature-info <feature>",
Category: "account",
Short: "show info for an account feature" + extra,
Long: `
Shows detailed info for a Heroku Labs feature on an account.
Example:
$ hk feature-info preboot
...
`,
}
func runAccountFeatureInfo(cmd *Command, args []string) {
if len(args) != 1 {
cmd.PrintUsage()
os.Exit(2)
}
feature, err := client.AccountFeatureInfo(args[0])
must(err)
fmt.Printf("Name: %s\n", feature.Name)
fmt.Printf("Docs: %s\n", feature.DocURL)
fmt.Printf("Enabled: %t\n", feature.Enabled)
fmt.Printf("Description: %s\n", feature.Description)
}
var cmdAccountFeatureEnable = &Command{
Run: runAccountFeatureEnable,
Usage: "account-feature-enable <feature>",
Category: "account",
Short: "enable an account feature" + extra,
Long: `
Enables a Heroku Labs feature on your account.
Example:
$ hk account-feature-enable pipelines
Enabled pipelines.
`,
}
func runAccountFeatureEnable(cmd *Command, args []string) {
if len(args) != 1 {
cmd.PrintUsage()
os.Exit(2)
}
featureName := args[0]
feature, err := client.AccountFeatureUpdate(featureName, true)
must(err)
log.Printf("Enabled %s.", feature.Name)
}
var cmdAccountFeatureDisable = &Command{
Run: runAccountFeatureDisable,
Usage: "account-feature-disable <feature>",
Category: "account",
Short: "disable an account feature" + extra,
Long: `
Disables a Heroku Labs feature on your account.
Example:
$ hk account-feature-disable pipelines
Disabled pipelines.
`,
}
func runAccountFeatureDisable(cmd *Command, args []string) {
if len(args) != 1 {
cmd.PrintUsage()
os.Exit(2)
}
featureName := args[0]
feature, err := client.AccountFeatureUpdate(featureName, false)
must(err)
log.Printf("Disabled %s.", feature.Name)
}