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

  1. Remove the positional key: run `wsh getvar --all` alone
  2. If you want a single variable, drop --all: `wsh getvar FOO`
  3. 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

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


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/59b35a9c73d3db14. Report an issue: GitHub.