lauf create
Scaffold a new script with a starter template.
Usage
bash
lauf create [name]
lauf create [name] --dir=<path>Parameters
| Parameter | Required | Description |
|---|---|---|
name | No | Name for the new script |
If the name is omitted, an interactive prompt asks for it.
Flags
| Flag | Description |
|---|---|
--dir | Target directory (absolute, or relative to config root) |
Behavior
- Resolves the script name (from the parameter or via prompt)
- Loads the nearest
lauf.config.ts - Determines the target directory:
- If
--diris provided with an absolute path, uses it directly - If
--diris provided with a relative path, resolves it from the config directory - If
--diris omitted, uses the first configured script pattern's directory (default:scripts/)
- If
- Creates the target directory if it doesn't exist
- Writes a
<name>.tsfile with the starter template
The generated script looks like:
ts
import { lauf, z } from 'laufen';
export default lauf({
description: 'TODO: describe what my-script does',
args: {
name: z.string().describe('TODO: describe this argument'),
},
async run(ctx) {
ctx.logger.info('Hello from my-script');
},
});Error Cases
| Scenario | Message |
|---|---|
| Config load failure | Failed to load lauf config: <error> |
| File already exists | File already exists: <path> |
| Directory creation failure | Failed to create directory <path>: <error> |
| Path escapes config root | Target directory escapes config root: <path> |
Notes
- Existing scripts will not be overwritten
- The target directory must be within the config root