Explains how to import error content from a local CSV file. Simple to use without any external API or authentication.
Quick Start with Template
Download the pre-made CSV template to get started right away.
TIP
After downloading, edit the data and run huh pull.
Writing a CSV File
The first row must be a header row. Follow the column structure below:
csv
ERR_LOGIN_FAILED,TOAST,Login failed,,,,,,
ERR_SESSION_EXPIRED,MODAL,Session has expired,Session Expired,,ERROR,Login Again,REDIRECT,/login
ERR_NOT_FOUND,PAGE,Page not found,404,/img/404.png,INFO,Go Home,REDIRECT,/TIP
Even if entered in lowercase, the CLI will automatically convert to uppercase. Custom types (BANNER, SNACKBAR, etc.) can also be used freely.
Column Rules
| Column Name | Required | Description |
|---|---|---|
trackId | Yes | Unique error ID (e.g., ERR_LOGIN_FAILED) |
type | Yes | TOAST, MODAL, PAGE, or custom type |
message | Yes | Error message. Supports template variables |
title | Error title (for modal, page) | |
image | Image URL (for page) | |
severity | INFO, WARNING, ERROR, CRITICAL, or custom severity | |
actionLabel | Action button text | |
actionType | REDIRECT, RETRY, BACK, DISMISS, or custom action | |
actionTarget | URL to navigate to for REDIRECT |
CSV Format Support
Uses an RFC 4180 compatible parser, supporting:
- Quoted fields:
"Hello, World" - Escaped quotes within fields:
"say ""hello""" - Newlines within fields (must be quoted)
- CRLF (
\r\n) and LF (\n) line endings - Automatic UTF-8 BOM removal
Configuration
.huh.config.json
json
{
"source": {
"type": "csv",
"filePath": "./errors.csv"
},
"output": "./src/huh.json"
}.huh.config.ts
ts
import { defineConfig } from '@sanghyuk-2i/huh-cli';
export default defineConfig({
source: {
type: 'csv',
filePath: './errors.csv',
},
output: './src/huh.json',
});filePath can be a relative or absolute path. Relative paths are resolved from process.cwd().
Fetching Data
bash
If successful, a JSON file will be generated at the output path.
Notes
- The CSV file must contain a header row + at least 1 data row.
- Uses a built-in parser with no additional dependencies.
- Files exported as CSV from Excel can be used directly.
