Initial commit

This commit is contained in:
2024-05-24 16:35:20 -04:00
commit aba755dc81
5 changed files with 48 additions and 0 deletions

2
.envrc Normal file
View File

@@ -0,0 +1,2 @@
export GUIX_PROFILE="$HOME/.guix-extra-profiles/go-build/go-build"
source "$GUIX_PROFILE/etc/profile"

0
README.md Normal file
View File

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module go.fixergrid.net/pguri2env
go 1.21.5

35
main.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"bufio"
"fmt"
"net/url"
"os"
)
func main() {
reader := bufio.NewScanner(os.Stdin)
if !reader.Scan() {
if reader.Err() != nil {
fmt.Fprintf(os.Stderr, "No input detected")
os.Exit(1)
}
}
line := reader.Text()
uri, err := url.Parse(line)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to parse input: %s", err)
os.Exit(1)
}
user := uri.User.Username()
pw, _ := uri.User.Password()
host := uri.Host
db := uri.EscapedPath()
fmt.Printf("export PGUSER=%s\n", user)
fmt.Printf("export PGPASSWORD=%s\n", pw)
fmt.Printf("export PGHOST=%s\n", host)
fmt.Printf("export PGDATABASE=%s\n", db)
}

8
manifest.scm Normal file
View File

@@ -0,0 +1,8 @@
(specifications->manifest
'(
"go@1.21"
"git"
"bash"
"glibc-locales"
"nss-certs"
"curl"))