Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version check to a number of commands #210

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/cmd/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/stripe/stripe-cli/pkg/requests"
"github.com/stripe/stripe-cli/pkg/stripe"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"
)

const webhooksWebSocketFeature = "webhooks"
Expand Down Expand Up @@ -101,6 +102,10 @@ func (lc *listenCmd) runListenCmd(cmd *cobra.Command, args []string) error {
return err
}

if !lc.printJSON {
version.CheckLatestVersion()
}

for _, event := range lc.events {
if _, found := validEvents[event]; !found {
fmt.Println(fmt.Sprintf("Warning: You're attempting to listen for \"%s\", which isn't a valid event", event))
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/logs/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stripe/stripe-cli/pkg/config"
logTailing "github.com/stripe/stripe-cli/pkg/logtailing"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"
)

const requestLogsWebSocketFeature = "request_logs"
Expand Down Expand Up @@ -145,6 +146,8 @@ func (tailCmd *TailCmd) runTailCmd(cmd *cobra.Command, args []string) error {
return err
}

version.CheckLatestVersion()

tailer := logTailing.New(&logTailing.Config{
APIBaseURL: tailCmd.apiBaseURL,
DeviceName: deviceName,
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"

"github.com/stripe/stripe-cli/pkg/open"
"github.com/stripe/stripe-cli/pkg/version"
)

var nameURLmap = map[string]string{
Expand Down Expand Up @@ -138,6 +139,8 @@ func (oc *openCmd) runOpenCmd(cmd *cobra.Command, args []string) error {
return nil
}

version.CheckLatestVersion()

if url, ok := nameURLmap[args[0]]; ok {
livemode, err := cmd.Flags().GetBool("livemode")
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type samplesCmd struct {
func newSamplesCmd() *samplesCmd {
samplesCmd := &samplesCmd{
cmd: &cobra.Command{
// TODO: fixtures subcommand
Use: "samples",
Short: `Sample integrations built by Stripe`,
Long: ``,
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/samples/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
gitpkg "github.com/stripe/stripe-cli/pkg/git"
"github.com/stripe/stripe-cli/pkg/samples"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"

"gopkg.in/src-d/go-git.v4"
)
Expand Down Expand Up @@ -41,6 +42,8 @@ func NewCreateCmd(config *config.Config) *CreateCmd {
}

func (cc *CreateCmd) runCreateCmd(cmd *cobra.Command, args []string) error {
version.CheckLatestVersion()

if len(args) == 0 {
return fmt.Errorf("Creating a sample requires at least 1 argument, received 0")
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/samples/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
s "github.com/stripe/stripe-cli/pkg/samples"
"github.com/stripe/stripe-cli/pkg/stripe"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"
)

// FixturesCmd prints a list of all the available sample projects that users can
Expand Down Expand Up @@ -35,6 +36,8 @@ func NewFixturesCmd(cfg *config.Config) *FixturesCmd {
}

func (fc *FixturesCmd) runFixturesCmd(cmd *cobra.Command, args []string) error {
version.CheckLatestVersion()

apiKey, err := fc.Cfg.Profile.GetAPIKey(false)
if err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/samples/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/stripe/stripe-cli/pkg/samples"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"
)

// ListCmd prints a list of all the available sample projects that users can
Expand All @@ -31,6 +32,8 @@ func NewListCmd() *ListCmd {
}

func (lc *ListCmd) runListCmd(cmd *cobra.Command, args []string) {
version.CheckLatestVersion()

fmt.Println("A list of available Stripe Sample integrations:")
fmt.Println()

Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stripe/stripe-cli/pkg/ansi"
"github.com/stripe/stripe-cli/pkg/status"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"
)

type statusCmd struct {
Expand Down Expand Up @@ -41,6 +42,10 @@ func newStatusCmd() *statusCmd {
}

func (sc *statusCmd) runStatusCmd(cmd *cobra.Command, args []string) error {
if sc.format != "json" {
version.CheckLatestVersion()
}

if sc.pollRate < 5 {
return fmt.Errorf("poll-rate must be at least 5 seconds, received %d", sc.pollRate)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/stripe/stripe-cli/pkg/requests"
"github.com/stripe/stripe-cli/pkg/stripe"
"github.com/stripe/stripe-cli/pkg/validators"
"github.com/stripe/stripe-cli/pkg/version"
)

const apiVersion = "2019-03-14"
Expand Down Expand Up @@ -98,6 +99,8 @@ needed to create the triggered event.
}

func (tc *triggerCmd) runTriggerCmd(cmd *cobra.Command, args []string) error {
version.CheckLatestVersion()

apiKey, err := Config.Profile.GetAPIKey(false)
if err != nil {
return err
Expand Down