Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide access to k6 CLI definition #4013

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

Provide access to k6 CLI definition #4013

szkiba opened this issue Oct 24, 2024 · 0 comments
Assignees

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:

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants