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

Provide access to k6 CLI definition #4013

Open
szkiba opened this issue Oct 24, 2024 · 2 comments
Open

Provide access to k6 CLI definition #4013

szkiba opened this issue Oct 24, 2024 · 2 comments
Labels

Comments

@szkiba
Copy link
Contributor

szkiba commented Oct 24, 2024

What

I would like the k6 command-line Go cobra CLI commands/subcommands to be publicly exposed. Additionally, I would find it practical if there was a single entry-point to obtain an instance of the k6 cobra CLI via a function call as suggested below.

Why

So that as a developer I do not have to attempt to rely on the command line argument from the shell perspective to be able to call k6 from another program reliably. Currently, launcher programs relying on the k6 binary struggle to properly parse k6 command arguments, and without proper programatically accessible definitions, launchers can't reliably identify available flags, and know which flags need arguments. Furthermore, creating our own definitions, and heuristics, and duplicating them in various projects creates technical debt and maintenance issues down the road.

How

The solution implied is to make k6's subcommand definitions accessible to external programs. This would replace current workarounds with a proper integration path. It would provide a single source of truth for command definitions. I suggest creating a cobra.Command factory function for the k6 root command in the public k6 go API.

Something like this:

package cmd

func New(ctx context.Context) (*cobra.Command, error) {
.
.
.

Connected issues

The root cause of the following issues is the lack of k6 subcommand definitions:

@olegbespalov
Copy link
Contributor

olegbespalov commented Nov 12, 2024

Personally, I see the value of the CLI definitions being exposed along with another related issue, #4015.

However, it extends the k6 API surface, so probably good to hear the thoughts of the @grafana/k6-core. Do you have any concerns/thoughts about that?

@olegbespalov olegbespalov removed their assignment Nov 12, 2024
@oleiade
Copy link
Member

oleiade commented Nov 13, 2024

I was part of the initial discussions around this. Added it to the "nice to have" list of things we could include for v1 (or v2's) API surface. I'm rather strongly for it considering it would a positive impact on our ecosystem 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants