# Nathapp CLI (na-cli) Documentation

The Nathapp CLI is a development utility designed to scaffold projects from templates and manage environment variable conversions between `.env` and YAML formats.

## Installation & Setup

If installed as a global package:
```bash
na --help
```

## Commands

### 1. Project Generation (`generate`, `gen`)
Scaffold a new project from a pre-defined template.

#### Interactive Mode (Default)
Simply run the command and follow the prompts:
```bash
na gen
```

#### Non-Interactive / Flag Mode
You can provide answers directly via command-line flags. If both `--template` and `--name` are provided, the CLI enters **Silent Mode**, suppressing all interactive prompts and using professional defaults for missing values.

**Common Flags:**
- `-t, --template`: Name of the template (e.g., `nestjs-api`, `k8s-helm-chart`).
- `-n, --name`: The name of the new project folder/package.
- `--author`: Project author name (defaults to `na-cli`).
- `-i, --install`: (Boolean) Run `npm install` after generation. No value needed (default: `false`).

**Template-Specific Flags:**

*   **NestJS API (`nestjs-api`):**
    - `--nestjs_api_platform`: Choose `express` or `fastify` (default: `fastify`).
*   **Database Schema (`db-schema`):**
    - `--db_master`: The master database name (default: `master`).
*   **K8s Helm Chart (`k8s-helm-chart`):**
    - `--k8s_chart_registry_host`: `aliyun`, `aws`, `dockerhub`, or `custom`.
    - `--k8s_image_name`: Full image name (default: `bitnami/kafka`).
    - `--k8s_image_version`: Version tag (default: `1.0.0`).
    - `--k8s_chart_kind`: `Deployment`, `StatefulSet`, or `CronJob` (default: `Deployment`).
    - `--k8s_chart_registry_region`: (For Aliyun/AWS) default: `ap-southeast-3`.
    - `--k8s_chart_aws_account_id`: (For AWS) default: `123456789`.

**Example:**
```bash
na gen -t nestjs-api -n my-backend -i
```

---

### 2. Smart Pathing (K8s)

The CLI understands the relationship between infrastructure projects and services. When generating a `k8s-helm-chart` inside a directory created by `k8s-deployment`, it will automatically detect and nest the new chart in the appropriate sub-folder:

1.  `services/charts/[name]` (Highest priority)
2.  `resources/charts/[name]`
3.  `services/[name]`
4.  `resources/[name]`

This allows you to manage modular services within a master deployment project without manually navigating to sub-folders.

---

### 3. Environment Variable Conversion

#### `.env` to YAML (`env-yml`)
Convert a standard dotenv file into a Nathapp-compatible YAML configuration.
```bash
na env-yml -i .env -o config.yaml
```
- `-i, --input`: Input path (default: `.env`).
- `-o, --output`: Output path (default: `config.yaml`).

#### YAML to `.env` (`yml-env`)
Convert a YAML configuration back into a standard dotenv file.
```bash
na yml-env -i config.yaml -o .env
```
- `-i, --input`: Input path (default: `config.yaml`).
- `-o, --output`: Output path (default: `.env`).

---

## Available Templates
The CLI currently supports the following project types:
- `db-schema`: Database migration and schema projects.
- `k8s-deployment`: Basic Kubernetes manifests.
- `k8s-helm-chart`: Comprehensive Helm chart bootstrapping.
- `mxw-base-api-express`: Express-based API boilerplate.
- `ts-library`: TypeScript library project.
- `nestjs-api`: Professional NestJS setup with platform choices.
- `vuexy-portal`: Frontend portal based on the Vuexy template.
