subcommand

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package subcommand provides functionality for registering k6 subcommand extensions.

This package allows external modules to register new subcommands that will be available in the k6 CLI. Subcommand extensions are registered during package initialization and are called when the corresponding subcommand is invoked.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterExtension

func RegisterExtension(name string, c Constructor)

RegisterExtension registers a subcommand extension with the given name and constructor function.

The name parameter specifies the subcommand name that users will invoke (e.g., "k6 <name>"). The constructor function will be called when k6 initializes to create the cobra.Command instance for this subcommand.

This function must be called during package initialization (typically in an init() function) and will panic if a subcommand with the same name is already registered.

The name parameter and the returned Command's Name() must match.

Types

type Constructor

type Constructor func(*state.GlobalState) *cobra.Command

Constructor is a function type that creates a new cobra.Command for a subcommand extension. It receives a GlobalState instance that provides access to configuration, logging, file system, and other shared k6 runtime state. The returned Command will be integrated into k6's CLI as a subcommand.

WARNING: The GlobalState parameter is read-only and must not be modified or altered in any way. Modifying the GlobalState can make k6 core unstable and lead to unpredictable behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL