Skip to content

Commit

Permalink
Merge pull request #26 from shipyard/update-readme
Browse files Browse the repository at this point in the history
Update the README
  • Loading branch information
maxsokolovsky authored Oct 13, 2023
2 parents 380b54e + 8f10c1f commit cccab61
Showing 1 changed file with 81 additions and 27 deletions.
108 changes: 81 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ A tool to manage Ephemeral Environments on the Shipyard platform.
brew install shipyard
```
## Get Your Token
## Login
Run `shipyard login` to initialize the CLI. This will prompt you to log in to Shipyard in the browser. The CLI will then
save your API token in a local config. You're ready to start running commands.
## Set Your Token Manually
Set your Shipyard API token as the value of the `SHIPYARD_API_TOKEN` environment variable.
Or set it as the value for the `api_token` config key.
You can get it by going to [your profile page](https://shipyard.build/profile).
### Set a Shipyard token
```bash
shipyard set token
```

You can get in touch with us at support@shipyard.build if you would like to enable API access for your org. If you have
any other questions feel free to join our [community slack](https://join.slack.com/t/shipyardcommunity/shared_invite/zt-x830cx39-BuiQKZwvhG7zGRTXAvojVQ).

You can get in touch with us at [support@shipyard.build](mailto:support@shipyard.build) if you would like to enable API
access for your org. If you have any other questions, feel free to join
our community [Slack](https://join.slack.com/t/shipyardcommunity/shared_invite/zt-x830cx39-BuiQKZwvhG7zGRTXAvojVQ).

Alternatively, you can use a configuration file stored in `$HOME/.shipyard/config.yaml` by default.
When you run the CLI for the first time, it will create a default empty config that you can then edit.
Expand All @@ -51,189 +57,237 @@ The values of your environment variables override their corresponding values in
## Basic usage
### Get all orgs you are a member of
```bash
shipyard get orgs
```

### Set the global default org

```bash
shipyard set org {org-name}
```

### Get the currently configured org

```bash
shipyard get org
```

### List all environments

```bash
shipyard get environments
```

Available flags:

| Name | Description | Type | Default Value |
| -| - | - | - |
| branch | Filter by branch name | string | |
| deleted| Return deleted environments | boolean | false |
| json | Print the complete JSON output | boolean | false |
| name | Filter by name of the application | string | |
| org-name | Filter by org name, if you are part of multiple orgs | string | your default org |
| page | Page number requested | int | 1 |
| page-size | Page size requested | int | 20 |
| pull-request-number | Filter by pull request number | string | |
| repo-name | Filter by repo name | string | |
| Name | Description | Type | Default Value |
|---------------------|------------------------------------------------------|---------|------------------|
| branch | Filter by branch name | string | |
| deleted | Return deleted environments | boolean | false |
| json | Print the complete JSON output | boolean | false |
| name | Filter by name of the application | string | |
| org-name | Filter by org name, if you are part of multiple orgs | string | your default org |
| page | Page number requested | int | 1 |
| page-size | Page size requested | int | 20 |
| pull-request-number | Filter by pull request number | string | |
| repo-name | Filter by repo name | string | |

**Examples:**

- List all environments running the repo `flask-backend` on branch `main`:

```bash
shipyard get environments --repo-name flask-backend --branch main
```

- List all deleted environments:

```bash
shipyard get environments --deleted
```

### Get details for a specifc environment by its UUID

```bash
shipyard get environment {environment_uuid}
```

Available flags:

| Name | Description | Type | Default Value |
| -| - | - | - |
| json | Print the complete JSON output | boolean | false |
| org-name | Filter by org name, if you are part of multiple orgs | string | your default org |
| Name | Description | Type | Default Value |
|----------|------------------------------------------------------|---------|------------------|
| json | Print the complete JSON output | boolean | false |
| org-name | Filter by org name, if you are part of multiple orgs | string | your default org |

### Stop a running environment

```bash
shipyard stop environment {environment_uuid}
```

### Restart a stopped environment

```bash
shipyard restart environment {environment_uuid}
```

### Cancel ongoing build for an environment

```bash
shipyard cancel environment {environment_uuid}
```

### Rebuild an environment

```bash
shipyard rebuild environment {environment_uuid}
```

### Revive a deleted environment

```bash
shipyard revive environment {environment_uuid}
```

### Get all services and exposed ports for an environment

```bash
shipyard get services --env {environment_uuid}
```

### Exec into a running environment's service
Execute any command with any arguments and flags in a given service for a **running** environment. Pass any command arguments after a double slash.

Execute any command with any arguments and flags in a given service for a **running** environment. Pass any command
arguments after a double slash.

```bash
shipyard exec --env {environment_uuid} --service {service_name} -- bash
```

### Port forward a running environment's service's port

```bash
shipyard port-forward --env {environment_uuid} --service {service_name} --ports {local_port}:{service_container_port}
```

### Get logs for a running environment's service

```bash
shipyard logs --env {environment_uuid} --service {service_name}
```

### Visit an environment

```bash
shipyard visit {environment_uuid}
```

Available flags:

| Name | Description | Type | Default Value |
| -| - | - | - |
| follow | Follow the logs output | boolean | false|
| tail| # of recent log lines to show | int | 3000 |

| Name | Description | Type | Default Value |
|--------|-------------------------------|---------|---------------|
| follow | Follow the logs output | boolean | false |
| tail | # of recent log lines to show | int | 3000 |

## Build executable from code:

You can make an executable by running the following command:

```bash
make
```

To run this new executable:

```bash
./shipyard
```

## Enable Autocompletion

### Bash
This script depends on the `bash-completion` package. If it is not installed already, you can install it via your OS's package manager.

This script depends on the `bash-completion` package. If it is not installed already, you can install it via your OS's
package manager.
To load completions in your current shell session:

```
source <(shipyard completion bash)
```

To load completions for every new session, execute the following once.

On Linux:

```
shipyard completion bash > /etc/bash_completion.d/shipyard
```

On macOS:

```
shipyard completion bash > $(brew --prefix)/etc/bash_completion.d/shipyard
```

### Zsh
If shell completion is not already enabled in your environment, you will need to enable it. You can execute the following once:

If shell completion is not already enabled in your environment, you will need to enable it. You can execute the
following once:

```
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

To load completions in your current shell session:

```
source <(shipyard completion zsh); compdef _shipyard shipyard
```

To load completions for every new session, execute the following once.

On Linux:

```
shipyard completion zsh > "${fpath[1]}/_shipyard"
```

On macOS:

```
shipyard completion zsh > $(brew --prefix)/share/zsh/site-functions/_shipyard
```

You will need to start a new shell for this setup to take effect.

### Fish

To load completions in your current shell session:

```
$ shipyard completion fish | source
```

To load completions for each session, execute once:

```
shipyard completion fish > ~/.config/fish/completions/shipyard.fish
```

### PowerShell

To load completions in your current shell session:

```
shipyard completion powershell | Out-String | Invoke-Expression
```

To load completions for every new session, run:

```
shipyard completion powershell > shipyard.ps1
```

and source this file from your PowerShell profile.

0 comments on commit cccab61

Please sign in to comment.