Add from env (#808)

This adds a little command that allows opening .env files as records.
My implementation removes comments and works with both quoted and
unquoted .env files.
This commit is contained in:
Piepmatz 2024-04-03 13:49:41 +02:00 committed by GitHub
parent a715b74453
commit df90d65eec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,11 @@
# Converts a .env file into a record
# may be used like this: open .env | load-env
# works with quoted and unquoted .env files
def "from env" []: string -> record {
lines
| split column '#' # remove comments
| get column1
| parse "{key}={value}"
| str trim value -c '"' # unquote values
| transpose -r -d
}