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

plugin update and plugin install should not accept no plugins in args. Closes #199 #204

Merged
merged 4 commits into from
Feb 24, 2021
Merged
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
20 changes: 18 additions & 2 deletions cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
plugins := append([]string{}, args...)
installSkipped := []string{}

if len(plugins) == 0 {
utils.ShowError(fmt.Errorf("you need to provide at least one plugin to install"))
fmt.Println()
cmd.Help()
fmt.Println()
return
}

if len(plugins) > 1 {
fmt.Println()
}
Expand Down Expand Up @@ -251,7 +259,7 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
fmt.Printf("\nTo update these plugins, please run: %s %s\n", constants.Bold("steampipe plugin update"), constants.Bold(strings.Join(installSkipped, " ")))
}

if len(args) > 1 {
if len(plugins) > 1 {
fmt.Println("")
}

Expand All @@ -273,6 +281,14 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
// full refs to the OCI image (us-docker.pkg.dev/steampipe/plugin/turbot/aws:1.0.0)
plugins := append([]string{}, args...)

if len(plugins) == 0 && !cmdconfig.Viper().GetBool("all") {
utils.ShowError(fmt.Errorf("you need to provide at least one plugin to update or use the %s flag", constants.Bold("--all")))
fmt.Println()
cmd.Help()
fmt.Println()
return
}

// we can't allow update and install at the same time
if cmdconfig.Viper().GetBool("all") {
if len(plugins) > 0 {
Expand Down Expand Up @@ -345,7 +361,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
}
fmt.Printf("\nTo install these plugins, please run: %s %s\n", constants.Bold("steampipe plugin install"), constants.Bold(strings.Join(updateSkipped, " ")))
}
if len(args) > 1 {
if len(plugins) > 1 {
fmt.Println("")
}

Expand Down