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

fix(cmd/influxd): suggest running with -h on error instead of printing usage #19995

Merged
merged 3 commits into from
Nov 11, 2020

Conversation

danxmoran
Copy link
Contributor

@danxmoran danxmoran commented Nov 11, 2020

Closes #19922

I'm not incredibly happy with this whack-a-mole approach, but it seemed like the most minimal approach. I'm going to open a separate issue for refactoring the CLI code here.

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • Rebased/mergeable
  • Tests pass
  • http/swagger.yml updated (if modified Go structs or API)
  • Feature flagged (if modified API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

@@ -28,23 +29,25 @@ func main() {

influxdb.SetBuildInfo(version, commit, date)

rootCmd := launcher.NewInfluxdCommand(context.Background(),
// FIXME
//generate.Command,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue: #19429

rootCmd := launcher.NewInfluxdCommand(context.Background(),
// FIXME
//generate.Command,
//restore.Command,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(As far as I can tell) this was replaced by the backup/restore commands in the influx CLI, so it's fine to remove the FIXME without a tracking issue

@danxmoran danxmoran force-pushed the dm-influxd-no-auto-usage-19922 branch from bd795d4 to 02d677b Compare November 11, 2020 20:55
@@ -16,6 +16,7 @@ func NewExportIndexCommand() *cobra.Command {
Long: `
This command will export all series in a TSI index to
SQL format for easier inspection and debugging.`,
Args: cobra.NoArgs,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the magic needed to trigger errors on unknown / typoed subcommands

@@ -178,7 +178,6 @@ var vaultConfig vault.Config

func setLauncherCMDOpts(l *Launcher, cmd *cobra.Command) {
cli.BindOptions(cmd, launcherOpts(l))
cmd.AddCommand(inspect.NewCommand())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this, the code was registering both influxd inspect and influxd run inspect commands. That felt like a mistake, but this technically a breaking change. I felt decently confident making the change because the public docs site only list influxd inspect, but I can revert if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is good with me; run shouldn't have any subcommands.

@@ -101,7 +100,7 @@ const (
MaxInt = 1<<uint(strconv.IntSize-1) - 1
)

func NewInfluxdCommand(ctx context.Context, subCommands ...*cobra.Command) *cobra.Command {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The humble beginnings of my quest to simplify launcher.go...

Copy link
Contributor

Choose a reason for hiding this comment

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

And a noble quest it is!

Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

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

These are nice UX improvements 👏

@@ -178,7 +178,6 @@ var vaultConfig vault.Config

func setLauncherCMDOpts(l *Launcher, cmd *cobra.Command) {
cli.BindOptions(cmd, launcherOpts(l))
cmd.AddCommand(inspect.NewCommand())
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good with me; run shouldn't have any subcommands.

@@ -101,7 +100,7 @@ const (
MaxInt = 1<<uint(strconv.IntSize-1) - 1
)

func NewInfluxdCommand(ctx context.Context, subCommands ...*cobra.Command) *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

And a noble quest it is!

@danxmoran danxmoran merged commit 518098e into master Nov 11, 2020
@danxmoran danxmoran deleted the dm-influxd-no-auto-usage-19922 branch November 11, 2020 21:37
@danxmoran danxmoran mentioned this pull request Nov 11, 2020
8 tasks
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.

Do not automatically print the help docs for influxd command
2 participants