Commit graph

407 commits

Author SHA1 Message Date
Mislav Marohnić
41e223869e Fix mapping port numbers to labels 2021-08-12 14:37:06 +02:00
Mislav Marohnić
db95f2f71f Add machine-readable output functionality to ports command 2021-08-12 14:35:49 +02:00
Mislav Marohnić
7a9d1fc331 Merge remote-tracking branch 'origin/main' into output-formats 2021-08-11 12:13:09 +02:00
Jose Garcia
619862a46b initial spike for multiple port support 2021-08-05 15:21:26 +00:00
Issy Long
4362b0b241 cmd/ghcs/delete: Display the interactive menu when there are no args
- Currently the flow to delete a single Codespace is `gh cs list`, copy
  and paste the Codespace name onto the end of `gh cs delete`.
- This improves consistency with other commands by letting the user
  choose which Codespace they want to delete, interactively. A Codespace
  name on the command-line still works too.
2021-08-05 15:00:18 +01:00
Jose Garcia
76aca39f5b Create status support 2021-08-04 17:35:11 +00:00
Mislav Marohnić
140a54a009 Add machine-readable output formats
- Default table output (when stdout is attached to a terminal) stays the same;
- When stdout is redirected, output tab-separated values and no header line;
- With `--json` flag, output structured JSON data.

Example:

    $ ghcs list --json
    [
      {
        "Branch": "main",
        "Created At": "2021-06-10T15:04:46+02:00",
        "Name": "mislav-playground-jvqj",
        "Repository": "mislav/playground",
        "State": "Shutdown"
      },
      {
        "Branch": "master",
        "Created At": "2021-07-15T15:51:08+02:00",
        "Name": "mislav-github-github-pwgg365xv",
        "Repository": "github/github",
        "State": "Shutdown"
      }
    ]
2021-08-04 15:58:27 +02:00
Jose Garcia
70f4a7b4b5 Re-introduce secrets export 2021-08-04 13:19:00 +00:00
Jose Garcia
d5003334e3 Remove secrets export 2021-08-03 13:43:09 +00:00
Jose Garcia
e57b390d4a dotfiles status spike 2021-08-03 13:42:34 +00:00
Jose Garcia
be794f1579 creation log support for cat and tail 2021-07-29 17:09:50 +00:00
Jose Garcia
58a055609d logs cmd spike and refactor of ssh tunnel methods 2021-07-29 10:57:51 -04:00
Mislav Marohnić
0d999ddaa1 Rework local extensions for Windows
Replace the implementation that relied on symlinks with the one that
create regular files that act like symlinks: they contain a reference to
the local directory where to find the extension.
2021-07-28 22:47:54 +02:00
Jose Garcia
cba40ad72a liveshare client upgrade 2021-07-28 08:33:06 -04:00
Mislav Marohnić
3931c16bd7 Provide version number at build time 2021-07-26 17:07:42 +02:00
Issy Long
c092a29350 cmd/ghcs/ssh: Add -c parameter for specifying a Codespace to SSH to
- This adds a `-c`, `--codespace` parameter to `ghcs ssh` to allow for
  non-interactively specifying a Codespace to SSH into, for instance if
  a user has recently done `ghcs list` and already knows which Codespace
  they want to access. Without a value for the `-c` parameter, the
  interactive prompt appears as usual.
2021-07-26 14:58:48 +01:00
CamiloGarciaLaRotta
7e49db3be3 config: bump to 0.7.1
Hoping to prove that Goreleaser & Homebrew run automatically
2021-07-22 10:33:00 -04:00
CamiloGarciaLaRotta
f35186485c Merge pull request #31 from github/feat/promptless-create
feat: introduce repo, branch and machine flags for ghcs create
2021-07-22 10:18:03 -04:00
Camilo Garcia La Rotta
14468baba6 config: bump to v0.7.0 2021-07-22 10:13:20 -04:00
CamiloGarciaLaRotta
89cf916e23 Merge branch 'main' into feat/promptless-create 2021-07-22 10:09:21 -04:00
Camilo Garcia La Rotta
3ef0226e20 fix: output available machine names on --machine error 2021-07-22 10:07:09 -04:00
CamiloGarciaLaRotta
2f467e3ddc Merge branch 'main' into feat/richer-delete 2021-07-22 09:55:20 -04:00
Issy Long
69865fa762 cmd/ghcs/main: Better description of ghcs as a whole
Co-authored-by: Camilo Garcia La Rotta <camilogarcialarotta@github.com>
2021-07-22 14:08:20 +01:00
Issy Long
b66d65379f cmd/ghcs/*.go: Better short descriptions of what commands do
- I ran `--help` on `ghcs code` and saw `ghcs code` and that was it,
  which was surprising. I expected a description.
- Here's a fix for all of the commands thus far to give them longer
  descriptions.
- I've only done "short" descriptions in Cobra terms, and removed the
  "long" descriptions as they seemed like they needed to be
  unnecessarily verbose.

Before:

```
❯ ghcs --help
Codespaces

Usage:
  ghcs [command]

Available Commands:
  code        code
  create      Create
  delete      delete
  help        Help about any command
  list        list
  ports       ports
  ssh         ssh

Flags:
  -h, --help      help for ghcs
  -v, --version   version for ghcs

Use "ghcs [command] --help" for more information about a command.

❯ ghcs ssh --help
ssh

Usage:
  ghcs ssh [flags]

Flags:
  -h, --help              help for ssh
      --profile string    SSH Profile
      --server-port int   SSH Server Port
```

After:

```
❯ ./ghcs --help
Codespaces

Usage:
  ghcs [command]

Available Commands:
  code        Open a GitHub Codespace in VSCode.
  create      Create a GitHub Codespace.
  delete      Delete a GitHub Codespace.
  help        Help about any command
  list        List GitHub Codespaces you have on your account.
  ports       Forward ports from a GitHub Codespace.
  ssh         SSH into a GitHub Codespace, for use with running tests/editing in vim, etc.

Flags:
  -h, --help      help for ghcs
  -v, --version   version for ghcs

Use "ghcs [command] --help" for more information about a command.

❯ ./ghcs ssh --help
SSH into a GitHub Codespace, for use with running tests/editing in vim, etc.

Usage:
  ghcs ssh [flags]

Flags:
  -h, --help              help for ssh
      --profile string    SSH Profile
      --server-port int   SSH Server Port
```
2021-07-22 11:07:23 +01:00
Camilo Garcia La Rotta
a68cda1469 refactor: break down Create() into smaller funcs 2021-07-21 20:54:18 -04:00
Camilo Garcia La Rotta
3db217fef0 feat: make sku survey optional 2021-07-21 20:27:22 -04:00
Camilo Garcia La Rotta
aab98ccc18 feat: break out repo and branch surveys 2021-07-21 20:06:05 -04:00
Camilo Garcia La Rotta
c751e88120 feat: introduce repo, branch and machine flags for ghcs create 2021-07-21 19:56:08 -04:00
Camilo Garcia La Rotta
5ca2fa5562 feat: ghcs delete repo REPO_NAME 2021-07-21 18:13:36 -04:00
Camilo Garcia La Rotta
7a0a8fa39c feat: ghcs delete all 2021-07-21 18:02:50 -04:00
Camilo Garcia La Rotta
0d6926e14b doc: root cmd description 2021-07-21 17:41:50 -04:00
Jose Garcia
532ee68165 Fix ssh command order 2021-07-21 14:04:42 -04:00
Jose Garcia
345e3e1b8a Update main.go 2021-07-21 13:50:19 -04:00
Jose Garcia
f7c80c99e7 Merge pull request #27 from github/jg/code-command
ghcs code command support
2021-07-21 13:48:10 -04:00
Jose Garcia
b44355d80d Merge pull request #26 from github/jg/secrets-and-server-port
Don't overwrite .zshenv, support server port for SSH, forward X11
2021-07-21 13:30:16 -04:00
Jose Garcia
c2b136a84f ghcs code command support 2021-07-21 13:28:47 -04:00
Jose Garcia
3e50fff2c9 X11 support 2021-07-21 10:22:33 -04:00
Kristján Oddsson
7a3e47ff3e Update error message link and wording. 2021-07-21 12:46:44 +01:00
Jose Garcia
e81bee6886 Doesn't overwrite .zshenv and supports server-port 2021-07-20 18:43:43 -04:00
Jose Garcia
8faee1e5a9 Update main.go 2021-07-20 08:09:48 -04:00
Jose Garcia
5e803aca79 Merge pull request #20 from github/jg/better-conn-handling
Bump go-liveshare w/ better connection handling and simpler ssh setup
2021-07-20 08:08:33 -04:00
Jose Garcia
6642fb520a Better connection handling and simpler ssh setup 2021-07-20 08:04:34 -04:00
Issy Long
2f8d00e0f8 Merge pull request #19 from github/version-cmd
cmd/ghcs/main: Add `--version` flag
2021-07-20 13:02:41 +01:00
Issy Long
4582fed1cc cmd/ghcs/main: Add --version flag
- This is built into Cobra the argument parser. Now `ghcs --version`
  exists.
- When we prepare to bump the version, we need to remember to update
  this value else the Homebrew formula, GitHub releases and the `ghcs
  --version` output will be mismatched.
- Fixes https://github.com/github/ghcs/issues/16.
2021-07-19 18:45:18 +01:00
Issy Long
cb29b11ab2 cmd/ghcs/main: Fail gracefully if GITHUB_TOKEN entirely unset
- I have my GitHub API token in my environment as
  `HOMEBREW_GITHUB_API_TOKEN`, so with things that need `GITHUB_TOKEN` I
  have to remember to `export GITHUB_TOKEN=$HOMEBREW_GITHUB_API_TOKEN`.
- I didn't for this tool, and got this unfriendly error message:

```
❯ ghcs list
Error: error getting user: Bad credentials
Usage:
  ghcs list [flags]

Flags:
  -h, --help   help for list

error getting user: Bad credentials
```

- This moves the "do you have a `GITHUB_TOKEN`" question to the very
  beginning (no guarantees about org SSO access, just a string that
  exists), erroring out with a nice message if users don't have that
  envvar set:

```
issyl0 in cetus in ~/repos/github/ghcs/cmd/ghcs on gracefully-fail-if-token-envvar-unset
❯ ./ghcs list
The GITHUB_TOKEN environment variable is required. Create a Personal Access Token with org SSO access at https://github.com/settings/tokens/new.

issyl0 in cetus in ~/repos/github/ghcs/cmd/ghcs on gracefully-fail-if-token-envvar-unset
❯ export GITHUB_TOKEN=$HOMEBREW_GITHUB_API_TOKEN

❯ ./ghcs list
+--------------------------------+--------------------+------------------------------------+----------+---------------------------+
|              NAME              |     REPOSITORY     |               BRANCH               |  STATE   |        CREATED AT         |
+--------------------------------+--------------------+------------------------------------+----------+---------------------------+
| issyl0-github-cat-ggrpj5fvwvr  | github/cat         | dependabot/bundler/graphql-1.12.13 | Shutdown | 2021-07-13T12:36:53+01:00 |
+--------------------------------+--------------------+------------------------------------+----------+---------------------------+
```
2021-07-19 18:10:15 +01:00
Jose Garcia
570a407bac Fix directive 2021-07-19 08:00:51 -04:00
Jose Garcia
798413848b Portfowarding private/public/forward now supported 2021-07-17 20:32:47 -04:00
Jose Garcia
3c42ab8f7a ghcs ports v1 2021-07-16 18:45:38 -04:00
Jose Garcia
44698ea1de Merge branch 'main' into mislav/timeout 2021-07-15 11:54:52 -04:00
Jose Garcia
ecea5b821a Give more time to start 2021-07-15 14:35:26 +00:00