Skip to content

Support array options for apify api -H/--header flag #1101

@patrikbraborec

Description

@patrikbraborec

Follow-up from review comment on #1076 (line R172): allow the -H/--header flag on apify api to be passed multiple times, so users can do:

apify api GET /v2/users/me -H XX:YY -H ZZ:AA

Current behavior

src/commands/api.ts:172-179 declares header as a single Flags.string. The flag can only be used once, so to send multiple headers users have to pass a JSON object:

apify api GET /v2/users/me -H '{"X-Foo": "bar", "X-Baz": "qux"}'

Desired behavior

Accept repeated -H key:value occurrences, matching the familiar curl ergonomics. The JSON-object form can stay as a convenience, but repeated flags should be the primary path.

Notes

  • Requires array/multiple-value support in the command framework's Flags.string (or a new Flags.stringArray-equivalent). Worth checking whether the framework already supports this before extending it.
  • Update the flag description once the behavior changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-dxIssues owned by the DX team.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions