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

[kbn/dev-utils] add RunWithCommands utility #72311

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Jul 17, 2020

As a part of moving the es-archiver to a more modern place I'd like to add a @kbn/dev-utils helper that uses many of the features of the run() helper, but with support for subcommands.

For an example of how this API works checkout the implementation I'm working on for my next PR here: https://github.com/spalger/kibana/blob/implement/es-archiver-package/packages/kbn-es-archiver/src/cli.ts

The gist of the feature is this:

import { RunWithCommands } from '@kbn/dev-utils'

new RunWithCommands({
  description: '...',
  globalFlags: { ... }, // same options as `run(..., { flags })`
})
  .command({
    name: 'foo',
    description: '...',
    flags: { ... }, // custom flags per command
    async run() {
      // ... do something when the "foo" command is executed ...
    }
  })
  .execute()

This helper replicates most of the functionality that we previously used commander for, and does it in a way that is async friendly, handles unexpected argument correctly, is type safe, and produces helpful documentation with --help or node scripts/xyz help foo.

top level help:
image

command specific help:
image

@spalger spalger added release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v7.10.0 v7.8.1 v7.9.0 v8.0.0 labels Jul 17, 2020
@spalger spalger marked this pull request as ready for review July 17, 2020 17:44
@spalger spalger requested a review from a team as a code owner July 17, 2020 17:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@brianseeders brianseeders left a comment

Choose a reason for hiding this comment

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

LGTM

async > streams for this

@spalger spalger merged commit 466380e into elastic:master Jul 17, 2020
@spalger spalger deleted the implement/dev-utils-run-commands branch July 17, 2020 20:53
spalger added a commit to spalger/kibana that referenced this pull request Jul 17, 2020
Co-authored-by: spalger <spalger@users.noreply.github.com>
spalger added a commit to spalger/kibana that referenced this pull request Jul 17, 2020
Co-authored-by: spalger <spalger@users.noreply.github.com>
spalger pushed a commit to spalger/kibana that referenced this pull request Jul 17, 2020
Co-authored-by: spalger <spalger@users.noreply.github.com>
(cherry picked from commit 466380e)
spalger added a commit that referenced this pull request Jul 17, 2020
Co-authored-by: spalger <spalger@users.noreply.github.com>
spalger added a commit that referenced this pull request Jul 17, 2020
#71535) and [7.9] [kbn/dev-utils] add RunWithCommands utility (#72311) (#72346)

Co-authored-by: spalger <spalger@users.noreply.github.com>
spalger added a commit that referenced this pull request Jul 17, 2020
Co-authored-by: spalger <spalger@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 20, 2020
* master:
  [Observability] Remove app logos (elastic#72259)
  Fix float percentiles line chart (elastic#71902)
  update chromedriver to 84 (elastic#72228)
  [esArchiver] actually re-delete the .kibana index if we lose recreate race (elastic#72354)
  [Maps] convert SavedGisMap to TS (elastic#72286)
  [DOCS] Removes occurrences of X-Pack Security and Reporting (elastic#72302)
  use WORKSPACE env var for stack_functional_integration tests, fix navigate path (elastic#71908)
  [Monitoring] Fix issue with ES node detail status (elastic#72298)
  [SIEM] Updates consumer in export_rule archive (elastic#72324)
  [kbn/dev-utils] add RunWithCommands utility (elastic#72311)
  [Security Solution][Endpoint][Exceptions] Only write manifest to policy when there are changes (elastic#72000)
  skip flaky suite (elastic#72339)
  [ML] Fix annotations pagination & change labels from letters to numbers (elastic#72204)
  [Lens] Fix switching with layers (elastic#71982)
  [Maps] 7.9 documenation updates (elastic#71893)
  docs: ✏️ add "Explore underlying data" user docs (elastic#70807)
  [Security Solution][Exceptions] - Remove initial add exception item button in builder (elastic#72215)
  Fix indentation level in code exploration doc (elastic#72274)
  register graph usage (elastic#72041)
  [Monitoring] Added a case for Alerting if security/ssl is disabled (elastic#71846)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v7.8.1 v7.9.0 v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants