Skip to content
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
8 changes: 4 additions & 4 deletions pkg/cmd/application/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewCreateCmd(f *cmdutil.Factory) *cobra.Command {
Use: "create",
Short: "Create a new Algolia application",
Long: heredoc.Doc(`
Create a new Algolia application and optionally configure it as a CLI profile.
Create a new Algolia application and optionally set it as the current application.
Requires an active session (run "algolia auth login" first).`),
Example: heredoc.Doc(`
# Create an application interactively (prompts for name, plan, and terms)
Expand All @@ -66,7 +66,7 @@ func NewCreateCmd(f *cmdutil.Factory) *cobra.Command {
# Create on a paid plan (requires a payment method on file)
$ algolia application create --name "My App" --region CA --plan grow --accept-terms

# Create and set the new profile as the default
# Create and set the new application as the current one
$ algolia application create --name "My App" --region CA --accept-terms --default

# Preview what would be created without actually creating it
Expand All @@ -85,10 +85,10 @@ func NewCreateCmd(f *cmdutil.Factory) *cobra.Command {
cmd.Flags().StringVar(&opts.Name, "name", "My First Application", "Name for the application")
cmd.Flags().StringVar(&opts.Region, "region", "", "Region code (e.g. EU, UK, USC, USE, USW)")
cmd.Flags().
StringVar(&opts.ProfileName, "profile-name", "", "Name for the CLI profile (defaults to app name)")
StringVar(&opts.ProfileName, "profile-name", "", "Alias for the application (defaults to the app name)")
cmd.Flags().
StringVar(&opts.Plan, "plan", "", "Self-serve plan to create the application on (free, grow, grow-plus)")
cmd.Flags().BoolVar(&opts.Default, "default", false, "Set the new profile as the default")
cmd.Flags().BoolVar(&opts.Default, "default", false, "Set the new application as the current one")
cmd.Flags().
BoolVar(&opts.DryRun, "dry-run", false, "Preview the create request without sending it")
cmd.Flags().
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/application/downgrade/downgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewDowngradeCmd(f *cmdutil.Factory) *cobra.Command {
Use: "downgrade",
Short: "Downgrade the current application to a lower-tier plan",
Long: heredoc.Doc(`
Change the application associated with the current CLI profile to a
Change the current application to a
lower-tier self-serve plan.

You must accept the target plan's terms of service before the change
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/application/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func NewListCmd(f *cmdutil.Factory) *cobra.Command {
Long: heredoc.Doc(`
List all Algolia applications associated with your account.
Requires an active session (run "algolia auth login" first).
Applications that already have a local CLI profile are marked.
You can select an unconfigured application to add it as a CLI profile.
Applications already configured on this machine are marked.
You can select an unconfigured application to configure it.
`),
Example: heredoc.Doc(`
# List applications
Expand Down Expand Up @@ -117,7 +117,7 @@ func runListCmd(opts *ListOptions) error {
profileName, configured := configuredAppIDs[app.ID]
label := fmt.Sprintf(" %s %s", app.ID, app.Name)
if configured {
fmt.Fprintf(opts.IO.Out, "%s %s\n", label, cs.Greenf("(profile: %s)", profileName))
fmt.Fprintf(opts.IO.Out, "%s %s\n", label, cs.Greenf("(configured: %s)", profileName))
} else {
fmt.Fprintf(opts.IO.Out, "%s %s\n", label, cs.Gray("(not configured)"))
unconfigured = append(unconfigured, app)
Expand All @@ -127,7 +127,7 @@ func runListCmd(opts *ListOptions) error {
fmt.Fprintln(opts.IO.Out)

if len(unconfigured) == 0 {
fmt.Fprintf(opts.IO.Out, "%s All applications are already configured as CLI profiles.\n", cs.SuccessIcon())
fmt.Fprintf(opts.IO.Out, "%s All applications are already configured.\n", cs.SuccessIcon())
return nil
}

Expand All @@ -138,7 +138,7 @@ func runListCmd(opts *ListOptions) error {
var wantConfigure bool
err = prompt.SurveyAskOne(
&survey.Confirm{
Message: "Would you like to configure an unconfigured application as a CLI profile?",
Message: "Would you like to configure one of the unconfigured applications?",
Default: true,
},
&wantConfigure,
Expand Down Expand Up @@ -173,7 +173,7 @@ func runListCmd(opts *ListOptions) error {
var setDefault bool
err = prompt.SurveyAskOne(
&survey.Confirm{
Message: "Set as the default profile?",
Message: "Set as the current application?",
Default: false,
},
&setDefault,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/application/planchange/planchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Run(opts *Options) error {
appID, err := opts.Config.Profile().GetApplicationID()
if err != nil {
return fmt.Errorf(
"no current application configured; configure a profile with \"algolia profile add\" or \"algolia application select\" first: %w",
"no current application configured; run \"algolia auth login\" or \"algolia application select\" first: %w",
err,
)
}
Expand Down
10 changes: 4 additions & 6 deletions pkg/cmd/application/selectapp/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ func NewSelectCmd(f *cmdutil.Factory) *cobra.Command {

cmd := &cobra.Command{
Use: "select",
Short: "Select an application to use as the active profile",
Short: "Select the current application",
Long: heredoc.Doc(`
Select an Algolia application to use as the default CLI profile.
Fetches your applications from the API and lets you pick one.

If the selected application already has a local profile, it is set
as the default. Otherwise, a new profile is created and set as default.
Select an Algolia application to use as the current application for
all CLI commands. Fetches your applications from the API and lets
you pick one.
`),
Example: heredoc.Doc(`
# Select interactively
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/application/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewUpdateCmd(f *cmdutil.Factory) *cobra.Command {
Use: "update",
Short: "Rename the current Algolia application",
Long: heredoc.Doc(`
Rename the application associated with the current CLI profile.
Rename the current application.
Requires an active application to be selected (run "algolia application select" first).
`),
Example: heredoc.Doc(`
Expand Down Expand Up @@ -69,7 +69,7 @@ func runUpdateCmd(opts *UpdateOptions) error {
appID, err := opts.Config.Profile().GetApplicationID()
if err != nil {
return fmt.Errorf(
"no current application configured; configure a profile with \"algolia profile add\" or \"algolia application select\" first: %w",
"no current application configured; run \"algolia auth login\" or \"algolia application select\" first: %w",
err,
)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/application/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewUpgradeCmd(f *cmdutil.Factory) *cobra.Command {
Use: "upgrade",
Short: "Upgrade the current application to a higher-tier plan",
Long: heredoc.Doc(`
Change the application associated with the current CLI profile to a
Change the current application to a
higher-tier self-serve plan.

Paid plans require a payment method on your account; the CLI can't
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/auth/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewCrawlerCmd(f *cmdutil.Factory) *cobra.Command {

cmd := &cobra.Command{
Use: "crawler",
Short: "Load crawler auth details for the current profile",
Short: "Configure the crawler API key for the current application",
Args: validators.NoArgs(),
RunE: func(cmd *cobra.Command, args []string) error {
return runCrawlerCmd(opts)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/auth/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func NewLoginCmd(f *cmdutil.Factory) *cobra.Command {
}

cmd.Flags().StringVar(&opts.AppName, "app-name", "", "Auto-select application by name")
cmd.Flags().StringVar(&opts.ProfileName, "profile-name", "", "Name for the CLI profile (defaults to application name)")
cmd.Flags().BoolVar(&opts.Default, "default", true, "Set the profile as the default")
cmd.Flags().StringVar(&opts.ProfileName, "profile-name", "", "Alias for the application (defaults to the application name)")
cmd.Flags().BoolVar(&opts.Default, "default", true, "Set the application as the current one")
cmd.Flags().BoolVar(&opts.NoBrowser, "no-browser", false, "Print the authorize URL instead of opening the browser")

return cmd
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/auth/signup/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func NewSignupCmd(f *cmdutil.Factory) *cobra.Command {
}

cmd.Flags().StringVar(&opts.AppName, "app-name", "", "Name for the first application")
cmd.Flags().StringVar(&opts.ProfileName, "profile-name", "", "Name for the CLI profile (defaults to application name)")
cmd.Flags().BoolVar(&opts.Default, "default", true, "Set the profile as the default")
cmd.Flags().StringVar(&opts.ProfileName, "profile-name", "", "Alias for the application (defaults to the application name)")
cmd.Flags().BoolVar(&opts.Default, "default", true, "Set the application as the current one")
cmd.Flags().BoolVar(&opts.NoBrowser, "no-browser", false, "Print the authorize URL instead of opening the browser")

return cmd
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
AuthMethodHelpMsg = `In order to use the 'crawler' commands, you will need to authenticate with the Algolia Crawler API. You can do so by either:
- Export your Algolia Crawler username and API Key as ALGOLIA_CRAWLER_USER_ID and ALGOLIA_CRAWLER_API_KEY environment variables.
- Add your Algolia Crawler 'crawler_user_id' and 'crawler_api_key' credentials to your profile file (~/.config/algolia/config.tml).`
- Run 'algolia auth crawler' to store your crawler API key securely in the OS keychain.`
)

// NewCrawlersCmd returns a new command to manage your Algolia Crawlers.
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/profile/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewAddCmd(f *cmdutil.Factory, runF func(*AddOptions) error) *cobra.Command
cmd := &cobra.Command{
Use: "add",
Args: validators.NoArgs(),
Short: "Add a new profile configuration to the CLI",
Short: "[Deprecated] Add a new profile configuration to the CLI",
Example: heredoc.Doc(`
# Add a new profile (interactive)
$ algolia profile add
Expand Down Expand Up @@ -139,6 +139,8 @@ func NewAddCmd(f *cmdutil.Factory, runF func(*AddOptions) error) *cobra.Command

// runAddCmd executes the add command
func runAddCmd(opts *AddOptions) error {
fmt.Fprintf(opts.IO.ErrOut,
"warning: `algolia profile add` is deprecated, use `algolia auth login` or `algolia application select` instead\n")
var defaultProfile *config.Profile
for _, profile := range opts.config.ConfiguredProfiles() {
if profile.Default {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/profile/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewProfileCmd(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "profile",
Aliases: []string{"profiles"},
Short: "Manage your Algolia CLI profiles",
Short: "[Deprecated] Manage your Algolia CLI profiles",
}

auth.DisableAuthCheck(cmd)
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/profile/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewListCmd(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
Use: "list",
Aliases: []string{"l"},
Args: validators.NoArgs(),
Short: "List the configured profile(s)",
Short: "[Deprecated] List the configured profile(s)",
Example: heredoc.Doc(`
# List the configured profiles
$ algolia profile list
Expand All @@ -51,6 +51,8 @@ func NewListCmd(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman

// runListCmd executes the list command
func runListCmd(opts *ListOptions) error {
fmt.Fprintf(opts.IO.ErrOut,
"warning: `algolia profile list` is deprecated, use `algolia application list` instead\n")
profiles := opts.config.ConfiguredProfiles()
if len(profiles) == 0 {
fmt.Fprintln(opts.IO.ErrOut, "No configured profiles")
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/profile/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewRemoveCmd(f *cmdutil.Factory, runF func(*RemoveOptions) error) *cobra.Co
Use: "remove <profile>",
Args: validators.ExactArgs(1),
ValidArgsFunction: cmdutil.ConfiguredProfilesCompletionFunc(f),
Short: "Remove the specified profile",
Short: "[Deprecated] Remove the specified profile",
Long: `Remove the specified profile from the configuration.`,
Example: heredoc.Doc(`
# Remove the profile named "my-app" from the configuration
Expand Down Expand Up @@ -81,6 +81,8 @@ func NewRemoveCmd(f *cmdutil.Factory, runF func(*RemoveOptions) error) *cobra.Co

// runRemoveCmd executes the remove command
func runRemoveCmd(opts *RemoveOptions) error {
fmt.Fprintf(opts.IO.ErrOut,
"warning: `algolia profile remove` is deprecated, profiles are replaced by `algolia application select` and the OS keychain\n")
if opts.DoConfirm {
var confirmed bool
err := prompt.Confirm(
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/profile/setdefault/setdefault.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewSetDefaultCmd(f *cmdutil.Factory, runF func(*SetDefaultOptions) error) *
Use: "setdefault <profile>",
Args: validators.ExactArgs(1),
ValidArgsFunction: cmdutil.ConfiguredProfilesCompletionFunc(f),
Short: "Set the default profile",
Short: "[Deprecated] Set the default profile",
Example: heredoc.Doc(`
# Set the default profile to "my-app"
$ algolia profile setdefault my-app
Expand All @@ -55,6 +55,8 @@ func NewSetDefaultCmd(f *cmdutil.Factory, runF func(*SetDefaultOptions) error) *

// runSetDefaultCmd executes the setdefault command
func runSetDefaultCmd(opts *SetDefaultOptions) error {
fmt.Fprintf(opts.IO.ErrOut,
"warning: `algolia profile setdefault` is deprecated, use `algolia application select` instead\n")
var defaultName string
for _, profile := range opts.config.ConfiguredProfiles() {
if profile.Default {
Expand Down
11 changes: 8 additions & 3 deletions pkg/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ func NewRootCmd(f *cmdutil.Factory) *cobra.Command {

cmd.PersistentFlags().
StringVarP(&f.Config.Profile().Name, "profile", "p", "", "The profile to use")
// Deprecated but kept visible in help (MarkDeprecated would also hide it).
cmd.PersistentFlags().
Lookup("profile").
Deprecated = "use --application-id or 'algolia application select' instead"
_ = cmd.RegisterFlagCompletionFunc("profile", cmdutil.ConfiguredProfilesCompletionFunc(f))

cmd.PersistentFlags().
StringVarP(&f.Config.Profile().ApplicationID, "application-id", "", "", "The application ID")
cmd.PersistentFlags().StringVarP(&f.Config.Profile().APIKey, "api-key", "", "", "The API key")
StringVarP(&f.Config.Profile().ApplicationID, "application-id", "", "", "The application ID (defaults to the current application, set with 'algolia application select')")
cmd.PersistentFlags().
StringVarP(&f.Config.Profile().APIKey, "api-key", "", "", "The API key (defaults to the key stored for the current application)")
cmd.PersistentFlags().
StringVarP(&f.Config.Profile().AdminAPIKey, "admin-api-key", "", "", "The admin API key")
_ = cmd.PersistentFlags().MarkDeprecated("admin-api-key", "use --api-key instead")
Expand Down Expand Up @@ -152,7 +157,7 @@ func Execute() exitCode {
fmt.Fprintf(stderr, "Authentication error: %s\n", err)
fmt.Fprintln(
stderr,
"Please run `algolia profile add` to configure your first profile.",
"Please run `algolia auth login` to get started.",
)
return authError
}
Expand Down
Loading