Skip to content

Add plugin install hints#1515

Merged
vcheung-stripe merged 5 commits intomasterfrom
vcheung-20260325-plugin-hints
Mar 30, 2026
Merged

Add plugin install hints#1515
vcheung-stripe merged 5 commits intomasterfrom
vcheung-20260325-plugin-hints

Conversation

@vcheung-stripe
Copy link
Copy Markdown
Collaborator

@vcheung-stripe vcheung-stripe commented Mar 25, 2026

Summary

In this PR, if the user tries to run a plugin command without having installed the plugin, we'll prompt them to install it. This also handles plugins that are in private preview by ensuring they have access to it first. These hints are currently hardcoded here for speed; I don't want to make a network call every time the user enters an unknown command to check if there's a plugin named that.

This does mean that plugin authors will have to hardcode their hint, but that is the tradeoff for this speed. I think this is fine because the hint is a nicety that doesn't preclude a plugin from being used.

For example, to add a new hint:

// AddHintCommands registers a hint command for each known plugin that is not
// present in installedPluginSet.
func AddHintCommands(rootCmd *cobra.Command, cfg *config.Config, installedPluginSet map[string]bool) {
	if !installedPluginSet["apps"] {
		rootCmd.AddCommand(
			newPluginHintCmd(cfg, "apps", "This plugin lets you build and manage Stripe Apps.").Command,
		)
	}
	if !installedPluginSet["generate"] {
		rootCmd.AddCommand(
			newPluginHintCmd(cfg, "generate", "The generate plugin creates skeleton files for you to get started.", withPrivatePreview()).Command,
		)
	}
	if !installedPluginSet["projects"] {
		rootCmd.AddCommand(
			newPluginHintCmd(cfg, "projects", "The projects plugin helps you scaffold and manage Stripe integration projects.").Command,
		)
	}
+if !installedPluginSet["pay"] {
+		rootCmd.AddCommand(
+			newPluginHintCmd(cfg, "pay", "The pay plugin lets you pay for things from the command line.").Command,
+		)
+	}
}

To remove the "private preview" behavior (not necessary because once the plugin is release publicly this logic is smart enough to see that, so maybe we even remove this option in the future):

// AddHintCommands registers a hint command for each known plugin that is not
// present in installedPluginSet.
func AddHintCommands(rootCmd *cobra.Command, cfg *config.Config, installedPluginSet map[string]bool) {
	if !installedPluginSet["apps"] {
		rootCmd.AddCommand(
			newPluginHintCmd(cfg, "apps", "This plugin lets you build and manage Stripe Apps.").Command,
		)
	}
	if !installedPluginSet["generate"] {
		rootCmd.AddCommand(
-			newPluginHintCmd(cfg, "generate", "The generate plugin creates skeleton files for you to get started.", withPrivatePreview()).Command,
+			newPluginHintCmd(cfg, "generate", "The generate plugin creates skeleton files for you to get started.").Command,
		)
	}
	if !installedPluginSet["projects"] {
		rootCmd.AddCommand(
			newPluginHintCmd(cfg, "projects", "The projects plugin helps you scaffold and manage Stripe integration projects.").Command,
		)
	}
}

Testing

Not logged in:

./stripe generate
the 'generate' plugin is in private preview; you must be logged in to use it — run `stripe login` to authenticate

Logged in but not flagged in:

./stripe generate
The 'generate' plugin is in private preview and not available for your account.

The generate plugin creates skeleton files for you to get started.

Your account: acct_1Plz52CjOw7iF6x1

Log into a different account using stripe login or reach out to Stripe support.

Logged in and available to install:

./stripe generate
The "generate" plugin is required to run this command.

The generate plugin creates skeleton files for you to get started.
You can also install it by using stripe plugin install generate.

Press Enter to install, or Ctrl+C to cancel.
✔ installation complete.
./stripe generate

Error: Please specify a command.

Usage:

stripe generate <command>

Commands:
  stripe generate custom-object <name>                          Generate a new custom object in your integration
  stripe generate custom-objects-sdk                            Generate SDK for custom objects from your Stripe App
  stripe generate extension <extension-point-id> <id>           Generate extension
  <implementation-type>

Options:
      --api-key           Your API key to use for the command                                                   [string]
      --color             turn on/off color output (on, off, auto)                                              [string]
      --config            config file (default is $HOME/.config/stripe/config.toml)                             [string]
      --device-name       device name                                                                           [string]
      --log-level         log level (debug, info, trace, warn, error)                         [string] [default: "info"]
  -p, -p, --project-name  the project name to read from for config                         [string] [default: "default"]
      --help              Show help                                                                            [boolean]
      --version           Show version number                                                                  [boolean]
  -i, --interactive       Run in interactive mode                                             [boolean] [default: false]

Apps

./stripe apps
The "apps" plugin is required to run this command.

This plugin lets you build and manage Stripe Apps.
You can also install it by using stripe plugin install apps.

Press Enter to install, or Ctrl+C to cancel.
✔ installation complete.

Projects

./stripe projects
The "projects" plugin is required to run this command.

The projects plugin helps you scaffold and manage Stripe integration projects.
You can also install it by using stripe plugin install projects.

Press Enter to install, or Ctrl+C to cancel.
✔ installation complete.

More than one arg

/stripe projects billing update
The "projects" plugin is required to run this command.

The projects plugin helps you scaffold and manage Stripe integration projects.
You can also install it by using stripe plugin install projects.

Press Enter to install, or Ctrl+C to cancel.
✔ installation complete.

@vcheung-stripe vcheung-stripe force-pushed the vcheung-20260325-plugin-hints branch from af59fcc to dd8cf03 Compare March 25, 2026 21:04
@vcheung-stripe vcheung-stripe force-pushed the vcheung-20260325-plugin-hints branch from dd8cf03 to 5573f4a Compare March 25, 2026 21:05
@vcheung-stripe vcheung-stripe changed the title Add plugin hints Add plugin install hints Mar 26, 2026
@anjg-stripe anjg-stripe self-requested a review March 26, 2026 19:32
@vcheung-stripe vcheung-stripe marked this pull request as ready for review March 27, 2026 16:21
@vcheung-stripe vcheung-stripe requested a review from a team as a code owner March 27, 2026 16:21
Copy link
Copy Markdown
Contributor

@vzhang-stripe vzhang-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@vcheung-stripe vcheung-stripe force-pushed the vcheung-20260325-plugin-hints branch from 0092a45 to 6186472 Compare March 27, 2026 19:44
@vcheung-stripe vcheung-stripe force-pushed the vcheung-20260325-plugin-hints branch from 6186472 to ad9663f Compare March 27, 2026 19:53
@vcheung-stripe vcheung-stripe merged commit b074ef0 into master Mar 30, 2026
13 checks passed
@vcheung-stripe vcheung-stripe deleted the vcheung-20260325-plugin-hints branch March 30, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants