to dotenv for formats
Convert a record into .env text.
Command Type
built-in
Signature
> to dotenv {flags}
Input/output types:
| input | output |
|---|---|
| record | string |
Examples
Write a record as .env text, quoting values that need it.
> {PORT: 8080, NAME: 'my app', GREETING: "it's"} | to dotenv
PORT=8080
NAME='my app'
GREETING="it's"Round-trip a record through .env text.
> {URL: 'http://${HOST}/', NOTE: "two\nlines"} | to dotenv | from dotenv
╭──────┬─────────────────╮
│ URL │ http://${HOST}/ │
│ NOTE │ two │
│ │ lines │
╰──────┴─────────────────╯Save a record to a .env file.
> {PORT: 8080, NAME: 'my app'} | save .envNotes
Each value is written as an external command would see it, so a PATH list is joined with the path separator and the to_string conversions in $env.ENV_CONVERSIONS apply, and null is written as an empty value. A value of plain characters is written bare; any other is single-quoted, or double-quoted with escapes when it holds a ' or a line break, so from dotenv reads back the same text. save writes a record to a file named like .env, .env.local or prod.env with this command.