Commit graph

76 commits

Author SHA1 Message Date
Mislav Marohnić
e327b42f79 Add gh help formatting topic & link to it from commands with JSON output 2021-04-14 18:27:15 +02:00
Mislav Marohnić
61a8049592 Extract JSON filtering functionality from gh api 2021-04-13 16:48:21 +02:00
Sam
9ec1e21d4c
Default to GHES host if only GHES is authenticated (#3286) 2021-03-30 16:51:00 +02:00
Kid
3a8313b4f7
Fix a typo in gh api 2021-03-08 22:14:29 +08:00
Mislav Marohnić
4e24f36495 Declare --jq, --template, --silent options mutually exclusive 2021-03-04 17:29:59 +01:00
Mislav Marohnić
d89756c94c Add test for api --jq 2021-03-04 17:10:48 +01:00
Mislav Marohnić
06eeea0737 Change the api --filter flag to api --jq 2021-03-04 17:05:31 +01:00
Mislav Marohnić
4c26d617d3 Merge remote-tracking branch 'origin/api-template' into api-jq 2021-03-04 17:00:41 +01:00
Mislav Marohnić
eb08774370 Assert that executeTemplate is invoked 2021-03-04 16:48:06 +01:00
Mislav Marohnić
f53ad7161a Add more api --template tests 2021-03-04 16:35:08 +01:00
Mislav Marohnić
0f27084f57 Add flag parsing test for api --template 2021-03-04 15:01:59 +01:00
Mislav Marohnić
07cb5e9e17 Merge remote-tracking branch 'origin' into api-template 2021-03-04 14:53:08 +01:00
Mislav Marohnić
440b59f8c3 Add the api --preview flag to opt into GitHub API previews
This was previously available manually via the `-H` flag, but it was
verbose, especially when opting into multiple previews.
2021-03-03 20:12:51 +01:00
Mislav Marohnić
03baeb2645 Add documentation and tests for api --filter 2021-03-03 19:24:38 +01:00
Mislav Marohnić
9f4eb55b66 Merge remote-tracking branch 'origin/api-template' into api-jq 2021-03-03 17:35:18 +01:00
Mislav Marohnić
bf97c6e273 Add template functions, documentation, tests 2021-03-02 20:07:04 +01:00
Mislav Marohnić
ed219ab5f3 Merge remote-tracking branch 'origin' into api-template 2021-03-02 18:31:28 +01:00
Mislav Marohnić
e32e6406a7 Add test for api --cache behavior 2021-03-01 16:04:19 +01:00
Mislav Marohnić
329ba1d57b Add --filter to api command to filter data using jq syntax 2021-02-22 17:51:58 +01:00
Mislav Marohnić
fd82d621d5 Add color function to api templates 2021-02-22 16:54:27 +01:00
Mislav Marohnić
517cfc2365 Add api --format flag for specifying an output template
With the `--format` flag, the value of the flag is parsed as a Go
template which is then evaluated against parsed response data.
https://golang.org/pkg/text/template
2021-02-22 16:15:02 +01:00
Mislav Marohnić
9dff05bf20 Add api --cache flag
Cache API responses on disk for a specified duration.
2021-02-22 16:13:24 +01:00
Mislav Marohnić
335f0117c0 Add more examples to api docs
- Clarify that fields need to be in "key=value" format
- Headers need to be in "key:value" format
- Contrast POST vs GET requests with params in examples
- Add an example of how to add HTTP headers
- Use backticks where applicable
2021-02-11 19:17:10 +01:00
vilmibm
e92cd43259 add IOStreams.ReadUserFile 2020-11-23 11:21:28 -08:00
Sam Coe
414de332fb
cleanup 2020-11-12 09:52:14 +03:00
Sam Coe
a79a0bbfd7
Add support for GH_TOKEN and GH_ENTERPRISE_TOKEN 2020-11-12 09:52:10 +03:00
Mislav Marohnić
fbff1fcfd2 Clarify the --hostname flag 2020-10-21 16:45:06 +00:00
Mislav Marohnić
228191bf85 Document GH_HOST for api command 2020-10-21 16:43:48 +00:00
Mislav Marohnić
460d55f723 Move HostnameValidator to ghinstance 2020-10-21 16:31:20 +00:00
wilso199
3ecb9de1a7 Adding a hostname flag option for use with gh api 2020-10-21 16:31:20 +00:00
Mislav Marohnić
50291aa6de Add PAGER support to the api command 2020-09-15 11:43:49 +02:00
Mislav Marohnić
ece17c4ce2 Add GITHUB_ENTERPRISE_TOKEN mention to api help 2020-09-07 21:37:55 +02:00
Mislav Marohnić
d8c5b7bfc0
Merge pull request #1517 from cli/select-host
Allow explicitly setting hostname for gh operations
2020-08-14 19:08:13 +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ć
e7a8b1e94e
Add documentation for ":branch" placeholder 2020-08-12 14:54:58 +02:00
Francisco Miamoto
800be370de propagate error from closure 2020-08-12 09:18:43 -03:00
Francisco Miamoto
bba2d6d204 improve test cases 2020-08-12 09:09:37 -03:00
Francisco Miamoto
b83342856b use factory method for branch
Also, improve the handling for the branch placeholder
2020-08-12 09:01:17 -03:00
Francisco Miamoto
9ebcec9aaf handle a detached head 2020-08-12 08:52:39 -03:00
Francisco Miamoto
0c10f67cd5 add branch placeholder for api calls 2020-08-12 08:52:39 -03:00
Martín Montes
27765f9987 Generalize REST error parsing 2020-08-07 14:22:20 +02:00
Mislav Marohnić
2ab06ab4d6
Merge pull request #1415 from cli/ghe-api
Add GHE compatibility to the API adapter
2020-08-03 17:19:20 +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ć
288d01318b Respect the hostname of current repository in queries 2020-07-23 22:31:08 +02:00
Mislav Marohnić
75086f0b80 💅 Improve readability of api example code
Tab indentation is replaced with two spaces to curb deep indentation.
2020-07-16 17:46:25 +02:00
Mislav Marohnić
9e4af479da Add command line docs for supported environment variables 2020-07-16 17:46:09 +02:00
AliabbasMerchant
7a04bf1672 api --silent Changes:
Show Response Headers (if requested) even with `--silent` flag
Shift silent tests to `Test_apiRun`
Changed usage string of `--silent` flag
2020-06-30 19:18:28 +05:30
AliabbasMerchant
aa43c55f60 Skip printing headers when --silent in api 2020-06-29 07:13:06 +05:30
AliabbasMerchant
5e56e31384 Added Test for --silent flag in api 2020-06-29 00:30:24 +05:30
AliabbasMerchant
cb2308c077 --silent flag in api 2020-06-29 00:15:34 +05:30