Commit graph

50 commits

Author SHA1 Message Date
Mislav Marohnić
d853ce5bc9 Avoid resolving executable() until requested at runtime
This is to avoid hitting the filesystem and resolving symlinks
unnecessarily. The value of executable is just used conditionally by a
handful of commands.
2021-09-24 14:42:41 +02:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Cuong Manh Le
6cf6bb4a44 Disable auth for cobra shell request completion hidden commands
Those hidden command are used by the shell completion scripts, but they
are not disabled auth check. Thus, the shell completion does not work
even the completion setup was done properly.

Fixes #4188
2021-08-25 01:35:49 +07:00
Heath Stewart
e2973453b5
Add helper template functions for rendering tables (#3519)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-08-23 21:00:25 +02:00
Mislav Marohnić
4b499be96b
Merge pull request #3942 from dscho/complete--repo-flag
Allow auto-completing the `--repo` values
2021-07-28 17:27:56 +02:00
Mislav Marohnić
d6b70beeaa List repos from non-default hostnames in completions for -R 2021-07-28 17:18:56 +02:00
Johannes Schindelin
b43f78bc19 completions: auto-complete --repo values
Looking at the locally-registered remotes, we have a pretty good idea
what `--repo` values are available. Let's complete them.

Helped by Nate Smith and Mislav Marohnić.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-07-28 15:36:30 +02:00
Mislav Marohnić
4d7625c8a0 Allow shell-completing multiple --json fields separated by commas 2021-07-21 16:12:38 +02:00
Sam
33c3fb5cdd
Merge pull request #3870 from cli/extensions-revisited
Improvements to gh extensions
2021-06-28 17:12:29 -07:00
Mislav Marohnić
1ec47d8191 Improvements to gh extensions
- Extensions on Windows now enabled through the `sh.exe` interpreter
- `sh.exe` now found on Windows when git was installed via scoop
- `gh extensions list` command shows origin repo for the extension
- `gh extensions upgrade --all` is required to upgrade all extensions
- Added `gh extensions remove`
- Shell completions now include aliases and extension names
- `gh` help output now lists available extension names
- Extensions are stored to XDG_DATA_HOME
2021-06-21 16:54:08 +02:00
Mislav Marohnić
8ff42bf28c Fix repo override 2021-06-17 17:58:46 +02:00
Mislav Marohnić
8dd1e12f64 Merge remote-tracking branch 'origin' into fix-actions-help 2021-06-17 16:13:34 +02:00
Mislav Marohnić
883943946a Add a global pre-run hook to handle auth check and repo override
With auth check being done via Cobra hooks, it is automatically skipped
for non-runnable commands and `-h/--help` flag usage.
2021-06-17 16:01:57 +02:00
Sam Coe
53fac59ef9
Cleanup factory/default and add tests 2021-06-15 09:19:16 -04:00
Mislav Marohnić
301a35eedc
Merge pull request #3621 from cli/export-data
Push data serialization concern into Exporter
2021-05-17 13:43:00 +02:00
Mislav Marohnić
b09c1f7a6f Add shell completion for the --json flag 2021-05-12 17:35:17 +02:00
Mislav Marohnić
5f0301c990 Have Exporter.Write automatically call ExportData on given data structure 2021-05-12 17:05:15 +02:00
Mislav Marohnić
654bd29ca0 Disallow unsupported values for --json flag 2021-04-14 19:58:58 +02:00
Mislav Marohnić
625505dcfb Fix assigning null Exporter 2021-04-14 19:11:08 +02:00
Mislav Marohnić
3ad41e3e65 Change JSON Exporter to an interface 2021-04-14 18:15:52 +02:00
Mislav Marohnić
abe452bb19 Add --json export flag for issues and pull requests
The `--json` flag accepts a list of GraphQL fields to query for and
output in JSON format. To get the list of available flags, run the
command with a blank value for `--json`. Additional `--jq` and
`--template` flags are available just like in `gh api`.
2021-04-13 20:29:31 +02:00
Mislav Marohnić
111e8dbcf2 Pass web browser to each individual command
This removes sensitivity to the BROWSER environment variable in tests
and makes it easier to verify the URL that the browser was invoked with
without having to stub sub-processes.
2021-03-19 21:22:37 +01:00
Mislav Marohnić
4e24f36495 Declare --jq, --template, --silent options mutually exclusive 2021-03-04 17:29:59 +01:00
Mislav Marohnić
aa5cf6c48a
Merge pull request #3075 from cli/credential-helper-absolute
Use absolute path when configuring gh as git credential
2021-03-04 13:51:24 +01:00
Mislav Marohnić
e96d974331
Merge pull request #3023 from cli/cancel-error-status
Issue/pr create: exit with nonzero status code when "Cancel" was chosen
2021-03-04 13:45:11 +01:00
Mislav Marohnić
98f1f5ec0d Use absolute path when configuring gh as git credential
This keeps git operations working even when PATH is modified, e.g. `brew
update` will work even though Homebrew runs the command explicitly
without `/usr/local/bin` in PATH.

Additionally, this inserts a blank value for `credential.*.helper` to
instruct git to ignore previously configured credential helpers, i.e.
those that might have been set up in system configuration files. We do
this because otherwise, git will store the credential obtained from gh
in every other credential helper in the chain, which we want to avoid.

Before:

    git config --global credential.https://github.com.helper '!gh auth git-credential'

After:

    git config --global credential.https://github.com.helper ''
    git config --global --add credential.https://github.com.helper '!/path/to/gh auth git-credential'
2021-03-03 16:20:21 +01:00
Mislav Marohnić
3444d00bee
Merge pull request #3018 from castaneai/pr-create-body-file
Add `pr create --body-file` flag
2021-03-02 15:21:17 +01:00
Mislav Marohnić
dd34cae112 Merge remote-tracking branch 'origin' into cancel-error-status 2021-03-02 13:52:07 +01:00
Mislav Marohnić
2ebdde1ddd Exit with status code "2" on user cancellation errors
This also stops printing "interrupt" after Ctrl-C is pressed.
2021-03-02 13:48:44 +01:00
Gowtham Munukutla
66d4307bce return msg instead of too many arguments 2021-02-24 18:05:11 +05:30
Gowtham Munukutla
56ead91702 Add helper function to validate exact args in cmdutil 2021-02-24 15:49:40 +05:30
Mislav Marohnić
fee7adf9ba Add issue create -F <file> flag and tests 2021-02-23 14:25:32 +01:00
Sam Coe
e21c5100fa
Properly check env auth tokens in CheckAuth 2020-12-01 11:44:14 -05:00
Alisson Santos
cf617e88f4 Extract repeated code to util function 2020-11-03 22:05:04 +01:00
Sam Coe
101bb90ab5
Add host back into repo flag description 2020-10-22 17:51:16 +02:00
Sam Coe
3f3c781ab6
Remove square brackets from persistent flag description to fix zsh autocomplete 2020-09-16 11:47:15 +02:00
vilmibm
cba401deb0 check parent annotatiosn for auth skip 2020-08-19 10:21:19 -05:00
vilmibm
0d48e8de59 linter appeasement 2020-08-18 18:03:48 -05:00
vilmibm
850a7ef243 print nice login message when no auth detected 2020-08-18 17:57:52 -05: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ć
47cef736f4 Fix GH_REPO override 2020-08-07 14:47:58 +02:00
Mislav Marohnić
12637d02d6 Isolate pr review command 2020-07-29 19:35:54 +02:00
vilmibm
f3eb092d7e isolate repo fork command and tweak usage
This commit is another isolation refactor, this time for repo fork.
However, I got fed up with the --remote="true|false|prompt" style of
flags and took this opportunity to switch to a set of bool flags:

--remote and --clone
--no-remote and --no-clone

the string args were really non standard and confusing; with only two
bools it was impossible to tell when to prompt.
2020-07-27 13:04:31 -05:00
vilmibm
1831d95433 isolated clone command
This commit hacks the existing repo clone tests into something usable by
the new isolated command. It went ok and was less effort than trying to
introduce the same kind of test format as repo view and gist create.
2020-07-23 16:40:31 -05:00
vilmibm
d92c80b560 just swap BaseRepo implementation 2020-07-23 11:58:22 -05:00
vilmibm
2a99ed9afb add ResolvedBaseRepo 2020-07-23 11:01:29 -05:00
Mislav Marohnić
b838ac4014 Improve no args error handler and extend it to other commands 2020-06-15 21:01:32 +02:00
Mislav Marohnić
acf0046718 api command: support {owner} and {repo} placeholders
When `{owner}` and `{repo}` strings are found in request path (for REST
requests) or `query` (for GraphQL), they are replaced with values from
the repository of the current working directory.
2020-06-11 15:00:29 +02:00
Mislav Marohnić
bef62faaea Make NewCmdApi testable 2020-05-20 15:21:35 +02:00
Mislav Marohnić
d8146cd16e Extract cmdutil package 2020-05-20 15:21:31 +02:00