# Project Commands

CLI commands for managing KeyEnv projects.

Source: https://keyenv.dev/docs/cli/projects/

Commands for initializing and managing KeyEnv projects.

## init

Initialize a new KeyEnv project in the current directory.

```bash
keyenv init [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| <code>-n, --name &lt;NAME&gt;</code> | Create a new project with this name |
| <code>-p, --project &lt;ID&gt;</code> | Link to an existing project by ID |

### Examples

```bash
# Interactive initialization
keyenv init

# Create a new project
keyenv init --name "my-api"

# Link to existing project
keyenv init --project abc123-def456-...
```

### What It Does

1. Prompts you to select or create a project
2. Creates a `.keyenv.toml` file with project configuration
3. Sets the default environment (usually `development`)

### Configuration File

```toml
# .keyenv.toml
project_id = "abc123-def456-..."
default_environment = "development"
```

---

## projects

Manage KeyEnv projects. Requires a subcommand.

```bash
keyenv projects <COMMAND>
```

### Subcommands

| Command | Description |
|---------|-------------|
| <code>list</code> | List all available projects |
| <code>show &lt;id&gt;</code> | Show details for a specific project |

---

## projects list

List all available projects.

```bash
keyenv projects list
```

### Examples

```bash
keyenv projects list
# Projects:
#   • my-api (abc123...) ← current
#   • frontend (def456...)
#   • shared-services (ghi789...)
```

### JSON Output

```bash
keyenv projects list --json
```

```json
{
  "projects": [
    {
      "id": "abc123-...",
      "name": "my-api",
      "current": true
    },
    {
      "id": "def456-...",
      "name": "frontend"
    }
  ],
  "current_project": "abc123-..."
}
```

---

## projects show

Show details for a specific project.

```bash
keyenv projects show <ID>
```

### Arguments

| Argument | Description |
|----------|-------------|
| <code>ID</code> | The project ID to show details for |

### Examples

```bash
keyenv projects show abc123-def456-...
# Project: my-api
#   ID: abc123-def456-...
#   Environments: development, staging, production
#   Created: 2024-01-15
```

### JSON Output

```bash
keyenv projects show abc123-def456-... --json
```

```json
{
  "id": "abc123-def456-...",
  "name": "my-api",
  "environments": ["development", "staging", "production"],
  "created_at": "2024-01-15T10:30:00Z"
}
```

---

## switch

Switch to a different project.

```bash
keyenv switch <PROJECT>
```

### Arguments

| Argument | Description |
|----------|-------------|
| <code>PROJECT</code> | Project name or ID to switch to |

### Examples

```bash
# Switch by name
keyenv switch frontend

# Switch by ID
keyenv switch def456-...
```

### Notes

- Updates your global config to use the selected project
- Affects all subsequent commands in any directory
- Use `keyenv init` in a project directory for per-directory configuration
