wavetermdev/waveterm · error
cannot specify key with --all
Error message
cannot specify key with --all
What it means
wsh getvar either fetches a single variable by key or dumps all variables with --all. These two modes are mutually exclusive, so getVarRun in cmd/wshcmd-getvar.go:73 rejects any positional argument supplied alongside --all. It is a pure usage-validation error from the CLI itself, not from the RPC layer.
Source
Thrown at cmd/wsh/cmd/wshcmd-getvar.go:74
sendActivity("getvar", WshExitCode == 0)
}()
// Resolve block to get zoneId
if blockArg == "" {
if getVarLocal {
blockArg = "this"
} else {
blockArg = "client"
}
}
fullORef, err := resolveBlockArg()
if err != nil {
return err
}
if getVarAllVars {
if len(args) > 0 {
return fmt.Errorf("cannot specify key with --all")
}
return getAllVariables(fullORef.OID)
}
// Single variable case - existing logic
if len(args) != 1 {
OutputHelpMessage(cmd)
return fmt.Errorf("requires a key argument")
}
key := args[0]
commandData := wshrpc.CommandVarData{
Key: key,
ZoneId: fullORef.OID,
FileName: getVarFileName,
}
resp, err := wshclient.GetVarCommand(RpcClient, commandData, &wshrpc.RpcOpts{Timeout: 2000})View on GitHub (pinned to a4447c1563)
Solutions
- Remove the positional key: run `wsh getvar --all` alone
- If you want a single variable, drop --all: `wsh getvar FOO`
- In scripts, guard the key: only pass it when not using --all, e.g. build args conditionally
Example fix
// before wsh getvar --all FOO // after wsh getvar --all # dump everything wsh getvar FOO # single key
Defensive patterns
Strategy: validation
Validate before calling
if [ -n "$key" ] && $use_all; then echo 'cannot combine key with --all'; exit 2; fi
Prevention
- Never pass a positional argument together with --all
- In scripts, build the command arguments conditionally based on whether --all is set
- Check `wsh getvar --help` for the mutually exclusive usage modes
When it happens
Trigger: Running `wsh getvar --all FOO` (or any positional key) against a resolved block/client zone while the --all flag is set.
Common situations: Scripting where the key is kept in a variable that is non-empty even in dump mode; copy-pasting `wsh getvar FOO` and appending --all to 'also get everything'; users misreading --all as 'also fetch this key'.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- requires a key argument
- no files or message provided
- too many files (maximum %d files allowed)
- stdin (-) can only be used once
- WAVETERM_TABID environment variable not set
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/59b35a9c73d3db14.
Report an issue: GitHub.