Documentation
¶
Overview ¶
Package completion configures shell completion predictors for the CLI.
Index ¶
Constants ¶
const ( ResourceName = "client:resource_name" ProjectName = "client:project_name" PostgresDatabases = "client:postgres_databases" MySQLDatabases = "client:mysql_databases" )
const DebugENV = "NCTL_COMPLETION_DEBUG"
DebugENV enables completion diagnostics on stderr.
Predictors have to swallow every error, as anything they return ends up in the candidate list of the shell. Without diagnostics a misconfigured client is indistinguishable from a project holding no resources.
Variables ¶
This section is empty.
Functions ¶
func Command ¶
func Command(ctx context.Context, parser *kong.Kong, creds api.Credentials, log *slog.Logger) (complete.Command, error)
Command builds the complete.Command tree for shell completion. The predictors query the API with the tokens and client secrets in creds, and report to log why they predict nothing.
func NewDebugLogger ¶
NewDebugLogger returns a logger writing to w why predictors predict nothing.
Every record starts on a new line, because the shell prints it in the middle of the line the user is currently completing.
func Register ¶
func Register(ctx context.Context, parser *kong.Kong, creds api.Credentials, log *slog.Logger) error
Register configures the Kong parser to intercept shell completion requests. The predictors query the API with the tokens and client secrets in creds, and report to log why they predict nothing, see NewDebugLogger.