Skip to content

Commit 175f23b

Browse files
committed
fix: updated Makefile default; aligned all help texts; misc
1 parent 164dbb5 commit 175f23b

File tree

18 files changed

+715
-67
lines changed

18 files changed

+715
-67
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
.PHONY: build clean
1+
.PHONY: build clean all
2+
.DEFAULT_GOAL := all
23

34
SHELL := /bin/bash
45

@@ -10,10 +11,17 @@ zsh-completion:
1011

1112
# for a speedier build than with goreleaser
1213
source_files := $(shell find . -name "*.go")
14+
1315
targetVar := streammachine.io/strm/cmd.CommandName
16+
1417
target := dstrm
18+
1519
ldflags := -X '${targetVar}=${target}'
20+
1621
${target}: ${source_files} Makefile
1722
go build -ldflags="${ldflags}" -o $@
23+
1824
clean:
1925
rm -f ${target}
26+
27+
all: ${target}

auth/auth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"os"
1717
)
1818

19-
var CommandName string
19+
var RootCommandName string
2020
var TokenFile string
2121

2222
const (
@@ -36,9 +36,9 @@ func login(apiHost string, s *string, cmd *cobra.Command) {
3636
authClient := &Auth{Uri: apiHost}
3737
authClient.AuthenticateLogin(s, &password)
3838
_, billingId := authClient.GetToken(false)
39-
fmt.Println("billingId", billingId)
39+
fmt.Println("Billing id:", billingId)
4040
filename := authClient.StoreLogin()
41-
fmt.Println("saved login to", filename)
41+
fmt.Println("Saved login to:", filename)
4242
}
4343

4444
func askPassword() string {

auth/cmd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ func LoginCmd() *cobra.Command {
2222
func PrintTokenCmd() *cobra.Command {
2323
cmd := &cobra.Command{
2424
Use: "access-token",
25-
Short: "print an access-token to stdout",
25+
Short: "Print your current access-token to stdout",
2626
Long: `Prints an access token that can be used in an http header.
27+
Note that this token might be expired, so a refresh may be required.
2728
Use token as follows:
2829
'Authorization: Bearer <token>'
2930
`,
@@ -38,7 +39,7 @@ func Refresh() *cobra.Command {
3839
cmd := &cobra.Command{
3940
Use: "refresh",
4041
Short: "Refresh an existing access-token",
41-
Long: `Not really necessary, the cli will auto-refresh.
42+
Long: `Not really necessary, the CLI will auto-refresh.
4243
`,
4344
Run: func(cmd *cobra.Command, args []string) {
4445
DoRefresh(apiHost(cmd))

auth/sts.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type token struct {
4343
func (authorizer *Auth) GetToken(quiet bool) (string, string) {
4444
if int64(authorizer.token.ExpiresAt)-30 < time.Now().Unix() {
4545
if !quiet {
46-
println("Refreshing sts token")
46+
println("Refreshing STS token")
4747
}
4848
authorizer.refresh()
4949
}
@@ -140,7 +140,7 @@ func (authorizer *Auth) LoadLogin() {
140140
filename := authorizer.getSaveFilename()
141141
b, err := ioutil.ReadFile(filename)
142142
if err != nil {
143-
cobra.CheckErr(fmt.Sprintf("No login information found. Use: `%v auth login` first.", CommandName))
143+
cobra.CheckErr(fmt.Sprintf("No login information found. Use: `%v auth login` first.", RootCommandName))
144144
}
145145
err = json.Unmarshal(b, &authorizer.token)
146146
cobra.CheckErr(err)
@@ -149,6 +149,6 @@ func (authorizer *Auth) LoadLogin() {
149149
func (authorizer *Auth) printToken() {
150150
fmt.Println(authorizer.token.IdToken)
151151
// these go to stderr, so the token is easy to capture in a script
152-
println("Expires at", time.Unix(int64(authorizer.token.ExpiresAt), 0).String())
153-
println("Billing-id", authorizer.token.BillingId)
152+
println("Expires at:", time.Unix(int64(authorizer.token.ExpiresAt), 0).String())
153+
println("Billing id:", authorizer.token.BillingId)
154154
}

cmd/egress.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var EgressCmd = &cobra.Command{
2020

2121
func init() {
2222
flags := EgressCmd.Flags()
23-
flags.String(sims.ClientIdFlag, "", "client id to be used for sending data")
24-
flags.String(sims.ClientSecretFlag, "", "client secret to be used for sending data")
23+
flags.String(sims.ClientIdFlag, "", "Client id to be used for receiving data")
24+
flags.String(sims.ClientSecretFlag, "", "Client secret to be used for receiving data")
2525

26-
}
26+
}

cmd/root.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var RootCmd = &cobra.Command{
5151
auth.ConfigPath = cfgPath
5252
utils.ConfigPath = cfgPath
5353

54-
auth.CommandName = CommandName
54+
auth.RootCommandName = CommandName
5555

5656
if cmd.Parent() != AuthCmd && cmd != CompletionCmd && cmd != VersionCmd && cmd.Name() != "help" {
5757
apiAuthUrl := utils.GetStringAndErr(cmd.Flags(), auth.ApiAuthUrlFlag)
@@ -132,12 +132,12 @@ func init() {
132132
cfgPath, err = utils.ExpandTilde("~/.config/stream-machine")
133133
cobra.CheckErr(err)
134134

135-
RootCmd.PersistentFlags().String(apiHostFlag, "apis.streammachine.io:443", "api host and port")
135+
RootCmd.PersistentFlags().String(apiHostFlag, "apis.streammachine.io:443", "API host and port")
136136
RootCmd.PersistentFlags().String(auth.EventAuthHostFlag, "https://auth.strm.services", "Security Token Service for events")
137137
RootCmd.PersistentFlags().String(auth.ApiAuthUrlFlag, "https://api.streammachine.io/v1", "Auth URL for user logins")
138138
RootCmd.PersistentFlags().StringVar(&auth.TokenFile, "token-file", "",
139-
"config file (default is $HOME/.config/stream-machine/strm-creds-<api-auth-host>.json)")
140-
RootCmd.PersistentFlags().String(egress.UrlFlag, "wss://out.strm.services/ws", "where to retrieve the events")
139+
"Token file that contains an access token (default is $HOME/.config/stream-machine/strm-creds-<api-auth-host>.json)")
140+
RootCmd.PersistentFlags().String(egress.UrlFlag, "wss://out.strm.services/ws", "Websocket to receive events from")
141141
setupVerbs()
142142
}
143143

@@ -207,4 +207,4 @@ func bindFlags(cmd *cobra.Command, v *viper.Viper) {
207207
cobra.CheckErr(err)
208208
}
209209
})
210-
}
210+
}

entity/batch_exporter/cmd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
func DeleteCmd() *cobra.Command {
1818
batchExporter := &cobra.Command{
1919
Use: "batch-exporter [name]",
20-
Short: "delete batch-exporter by name",
20+
Short: "Delete a Batch exporter by name",
2121
Run: func(cmd *cobra.Command, args []string) {
2222
del(&args[0])
2323
},
@@ -31,7 +31,7 @@ func DeleteCmd() *cobra.Command {
3131
func GetCmd() *cobra.Command {
3232
return &cobra.Command{
3333
Use: "batch-exporter [name]",
34-
Short: "get batch-exporter by name",
34+
Short: "Get Batch exporter by name",
3535
Run: func(cmd *cobra.Command, args []string) {
3636
get(&args[0], cmd)
3737
},
@@ -42,7 +42,7 @@ func GetCmd() *cobra.Command {
4242
func ListCmd() *cobra.Command {
4343
return &cobra.Command{
4444
Use: "batch-exporters",
45-
Short: "List batch-exporters",
45+
Short: "List Batch exporters",
4646
Run: func(cmd *cobra.Command, args []string) {
4747
list()
4848
},

entity/event_contract/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/spf13/cobra"
55
func GetCmd() *cobra.Command {
66
return &cobra.Command{
77
Use: "event-contract [name]",
8-
Short: "get event-contract by name",
8+
Short: "Get Event Contract by name",
99
Run: func(cmd *cobra.Command, args []string) {
1010
get(&args[0])
1111
},
@@ -16,7 +16,7 @@ func GetCmd() *cobra.Command {
1616
func ListCmd() *cobra.Command {
1717
return &cobra.Command{
1818
Use: "event-contracts",
19-
Short: "List event-contracts",
19+
Short: "List Event Contracts",
2020
Run: func(cmd *cobra.Command, args []string) {
2121
list()
2222
},

entity/kafka_cluster/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/spf13/cobra"
55
func GetCmd() *cobra.Command {
66
return &cobra.Command{
77
Use: "kafka-cluster [name]",
8-
Short: "get kafka-cluster by name",
8+
Short: "Get Kafka cluster by name",
99
Run: func(cmd *cobra.Command, args []string) {
1010
get(&args[0])
1111
},
@@ -16,7 +16,7 @@ func GetCmd() *cobra.Command {
1616
func ListCmd() *cobra.Command {
1717
return &cobra.Command{
1818
Use: "kafka-clusters",
19-
Short: "List kafka-clusters",
19+
Short: "List Kafka clusters",
2020
Run: func(cmd *cobra.Command, args []string) {
2121
list()
2222
},

entity/kafka_exporter/cmd.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const (
1414
func DeleteCmd() *cobra.Command {
1515
return &cobra.Command{
1616
Use: "kafka-exporter [name]",
17-
Short: "Delete a kafka-exporter",
18-
Long: `Delete a kafka-exporter.
19-
If a kafka-exporter has dependents (like kafka-users), you can use
17+
Short: "Delete a Kafka exporter",
18+
Long: `Delete a Kafka exporter.
19+
If a kafka-exporter has dependents (like Kafka users), you can use
2020
the 'recursive' option to get rid of those also.
2121
Returns everything that was deleted. `,
2222
Run: func(cmd *cobra.Command, args []string) {
@@ -31,7 +31,7 @@ func DeleteCmd() *cobra.Command {
3131
func GetCmd() *cobra.Command {
3232
return &cobra.Command{
3333
Use: "kafka-exporter [name]",
34-
Short: "get kafka-exporter by name",
34+
Short: "Get Kafka exporter by name",
3535
Run: func(cmd *cobra.Command, args []string) {
3636
recursive, _ := cmd.Flags().GetBool("recursive")
3737
get(&args[0], recursive)
@@ -44,7 +44,7 @@ func GetCmd() *cobra.Command {
4444
func ListCmd() *cobra.Command {
4545
return &cobra.Command{
4646
Use: "kafka-exporters",
47-
Short: "List kafka-exporters",
47+
Short: "List Kafka exporters",
4848
Run: func(cmd *cobra.Command, args []string) {
4949
flag, _ := cmd.Root().PersistentFlags().GetBool("recursive")
5050
list(flag)
@@ -56,7 +56,7 @@ func CreateCmd() *cobra.Command {
5656

5757
kafkaExporter := &cobra.Command{
5858
Use: "kafka-exporter [stream-name]",
59-
Short: "create a kafka-exporter",
59+
Short: "Create a Kafka exporter",
6060
Run: func(cmd *cobra.Command, args []string) {
6161
streamName := &args[0]
6262
create(streamName, cmd)

entity/kafka_user/cmd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
func DeleteCmd() *cobra.Command {
1414
return &cobra.Command{
1515
Use: "kafka-user [name]",
16-
Short: "Delete a kafka-user",
16+
Short: "Delete a Kafka user",
1717
Run: func(cmd *cobra.Command, args []string) {
1818
del(&args[0])
1919
},
@@ -25,7 +25,7 @@ func DeleteCmd() *cobra.Command {
2525
func GetCmd() *cobra.Command {
2626
return &cobra.Command{
2727
Use: "kafka-user [name]",
28-
Short: "get a kafka-user",
28+
Short: "Get Kafka user",
2929
Run: func(cmd *cobra.Command, args []string) {
3030
get(&args[0])
3131
},
@@ -37,7 +37,7 @@ func GetCmd() *cobra.Command {
3737
func ListCmd() *cobra.Command {
3838
return &cobra.Command{
3939
Use: "kafka-users [kafka-exporter-name]",
40-
Short: "List kafka-users",
40+
Short: "List Kafka users",
4141
Run: func(cmd *cobra.Command, args []string) {
4242
list(&args[0])
4343
},
@@ -49,7 +49,7 @@ func ListCmd() *cobra.Command {
4949
func CreateCmd() *cobra.Command {
5050
kafkaUser := &cobra.Command{
5151
Use: "kafka-user [exporter-name]",
52-
Short: "create a kafka-user on a named kafka-exporter",
52+
Short: "Create a Kafka user on a Kafka exporter",
5353
Run: func(cmd *cobra.Command, args []string) {
5454
streamName := &args[0]
5555
create(streamName, cmd)

entity/key_stream/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/spf13/cobra"
55
func GetCmd() *cobra.Command {
66
return &cobra.Command{
77
Use: "key-stream [name]",
8-
Short: "get key-stream by name",
8+
Short: "Get key stream by name",
99
Run: func(cmd *cobra.Command, args []string) {
1010
get(&args[0])
1111
},

entity/schema/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/spf13/cobra"
55
func GetCmd() *cobra.Command {
66
return &cobra.Command{
77
Use: "schema [name]",
8-
Short: "get schema by name",
8+
Short: "Get schema by name",
99
Run: func(cmd *cobra.Command, args []string) {
1010
get(&args[0])
1111
},

entity/sink/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const (
1010
func GetCmd() *cobra.Command {
1111
return &cobra.Command{
1212
Use: "sink [name]",
13-
Short: "get sink by name",
13+
Short: "Get sink by name",
1414
Run: func(cmd *cobra.Command, args []string) {
1515
recursive, _ := cmd.Flags().GetBool("recursive")
1616
get(&args[0], recursive)

entity/stream/cmd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ func CreateCmd() *cobra.Command {
88

99
stream := &cobra.Command{
1010
Use: "stream [name]",
11-
Short: "create a stream",
11+
Short: "Create a stream",
1212
Run: func(cmd *cobra.Command, args []string) {
1313
create(args, cmd)
1414

@@ -53,7 +53,7 @@ func DeleteCmd() *cobra.Command {
5353
func GetCmd() *cobra.Command {
5454
return &cobra.Command{
5555
Use: "stream [name]",
56-
Short: "A brief description of your command",
56+
Short: "Get stream by name",
5757
Run: func(cmd *cobra.Command, args []string) {
5858
recursive, _ := cmd.Flags().GetBool("recursive")
5959
get(&args[0], recursive)
@@ -71,4 +71,4 @@ func ListCmd() *cobra.Command {
7171
list(recursive)
7272
},
7373
}
74-
}
74+
}

0 commit comments

Comments
 (0)