Commit graph

10 commits

Author SHA1 Message Date
Sam Coe
ebcf3a1022
Set default Accept header for api command when one is not specified (#8303) 2023-11-06 15:22:32 +01:00
ffalor
e4e7bf5c8c
force method to uppercase (#7514)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2023-06-01 13:54:56 +00:00
Mislav Marohnić
7a814b31c2
api: support array params in GET queries (#7513) 2023-05-31 20:23:31 +02:00
Mislav Marohnić
c5c2f9cc10
Supported passing nested JSON arrays/objects to api command via fields (#6614)
Examples:

	-f labels[]=bug -f labels[]=p1
        #=> { "labels": ["bug", "p1"] }

	-f branch[name]=patch-1 -F branch[protected]=true
        #=> { "branch": { "name": "patch-1", "protected": true }

	-f labels[][name]=bug-1 -f labels[][color]=red
        #=> { "labels": [{ "name": "bug-1", "color": "red" }] }
2022-12-22 20:12:00 +01:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Mislav Marohnić
c095a4bead Allow explicitly specifying the hostname for gh operations
Accept the "HOST/OWNER/REPO" syntax or passing a full URL for both the
`--repo` flag and the GH_REPO environment variable and allow setting
GH_HOST environment variable to override just the hostname for
operations that assume "github.com" by default.

Examples:

    $ gh repo clone example.org/owner/repo
    $ GH_HOST=example.org gh repo clone repo

    $ GH_HOST=example.org gh api user
    $ GH_HOST=example.org gh gist create myfile.txt

    $ gh issue list -R example.org/owner/repo
    $ gh issue list -R https://example.org/owner/repo.git
    $ GH_REPO=example.org/owner/repo gh issue list
2020-08-12 16:16:34 +02:00
Mislav Marohnić
d26cd64745 Support GraphQL operationName in gh api command
GraphQL supports supplying multiple queries in the `query` parameter,
but an additional `operationName` parameter is then required to select
the query to execute.

Previously, it was impossible to pass `operationName` since it would get
serialized under `variables`, but it needs to be a top-level parameter.
With this change, `operationName` is a special GraphQL parameter name
just like `query` already is.
2020-07-29 16:47:33 +02:00
Mislav Marohnić
7033021637 gh api: fix passing file/stdin contents via field arguments
Reading from file via `-F foo=@myfile.txt` syntax would result in
`[]byte` Go type, which by default gets serialized to JSON in base64
format, which we don't want here.

Traverse all parameters and convert any `[]byte` into `string` before
JSON serialization.
2020-06-03 16:00:52 +02:00
Mislav Marohnić
bef62faaea Make NewCmdApi testable 2020-05-20 15:21:35 +02:00
Mislav Marohnić
f58e0bf710 Add api tests 2020-05-20 15:21:32 +02:00