gitlink-cli/doc/changes/api-batch-save-vars.md

1.2 KiB

API Batch Saved Variables

Summary

Enhances gitlink-cli api --batch-file so a request can save fields from its response and reuse them in later requests.

A batch request can now include:

{
  "name": "find-issue",
  "method": "GET",
  "path": "/v1/{{owner}}/{{repo}}/issues",
  "save": {
    "issue": "issues.0.id",
    "subject": "data.issues.0.subject"
  }
}

Later requests can reference {{issue}} and {{subject}} in name, path, query, body, and save fields.

JSON path syntax

  • Dot-separated object fields: issues.0.id
  • Array indexes: issues.0.id
  • Optional leading data. is accepted for readability: data.issues.0.id

Safety and behavior

  • --dry-run now tolerates variables that will be produced by earlier save entries, preserving unresolved {{var}} placeholders in the preview.
  • If a save path is missing during execution, the batch result records the error and obeys --continue-on-error.
  • Each result includes a saved map when variables were extracted successfully.

Validation

git diff --check
GOPROXY=https://goproxy.cn,direct go test ./cmd/api
go vet ./cmd/api
GOPROXY=https://goproxy.cn,direct go test ./...
go vet ./...