# TunnelHub CLI

[![npm version](https://badge.fury.io/js/%40tunnelhub%2Fcli.svg)](https://www.npmjs.com/package/@tunnelhub/cli)

TunnelHub CLI is a command-line interface tool that helps developers interact with TunnelHub services directly from their terminal. It simplifies managing environments, packages, and automations for creating and deploying integrations in the TunnelHub ecosystem.

## Features

- Secure authentication with TunnelHub accounts
- Environment management and listing
- Package creation and listing
- Automation creation, listing, and deployment
- Support for different runtime engines (Lambda and ECS Fargate)
- Intuitive command-line interface with guided prompts

## Installation

To use the TunnelHub CLI, you need Node.js installed on your system. Download it from [nodejs.org](https://nodejs.org) if you don't have it yet.

Install the TunnelHub CLI globally using npm:

```bash
npm install -g @tunnelhub/cli
```

Or using yarn:

```bash
yarn global add @tunnelhub/cli
```

After installation, you can access the CLI using either `tunnelhub` or the shorthand `th` command.

## Usage

### Authentication

Before using TunnelHub CLI, you need to authenticate with your TunnelHub account:

```bash
tunnelhub login
```

This will open a browser window for OAuth authentication. If you prefer password-based authentication:

```bash
tunnelhub login --password
```

To verify your authentication status:

```bash
tunnelhub login-check
```

To log out and remove your credentials:

```bash
tunnelhub logout
```

### Managing Environments

List your available environments:

```bash
tunnelhub list-environments
```

### Working with Packages

List your existing packages:

```bash
tunnelhub list-packages
```

Create a new package:

```bash
tunnelhub create-package
```

### Working with Automations

List your automations:

```bash
tunnelhub list-automations
```

Create a new automation:

```bash
tunnelhub create-automation --env [environment-id]
```

When creating automations, you can choose from four base designs:
- No delta (individual)
- No delta (batch)
- Delta (individual)
- Delta (batch)

Deploy an automation:

```bash
tunnelhub deploy-automation --env [environment-id] --automation [automation-id]
```

### Help and Version

Display the help menu:

```bash
tunnelhub --help
```

Check the CLI version:

```bash
tunnelhub --version
```

## Common Workflows

### Creating and Deploying an Automation

1. Log in to your TunnelHub account:
   ```bash
   tunnelhub login
   ```

2. List your environments and note the environment ID where you want to create the automation:
   ```bash
   tunnelhub list-environments
   ```

3. Create a new automation:
   ```bash
   tunnelhub create-automation --env [environment-id]
   ```

4. Follow the interactive prompts to configure your automation settings, including the automation type, runtime engine, and other parameters.

5. Deploy your automation:
   ```bash
   tunnelhub deploy-automation --env [environment-id] --automation [automation-id]
   ```

## Support

If you encounter any issues or have questions about using TunnelHub CLI, please visit our [GitHub repository](https://github.com/tunnelhub/cli) or contact support at the email provided in the package information.

## License

TunnelHub CLI is licensed under the ISC License.