A command-line toolkit written in Go for working with configuration files and managing them as resources in a PostgreSQL database.
Built with Cobra, sqlx, golang-migrate, and goccy/go-yaml.
- Convert between
JSONandYAML(auto-detects input format from extension) - Persist JSON/YAML resources in PostgreSQL as
JSONB - CRUD over stored resources:
save,list,get,update,delete - Migrations via
goku migrate up/goku migrate down - Configurable database connection through the
GOKU_DB_URLenvironment variable
- Go 1.24 or newer
- PostgreSQL (for any command that touches the database)
git clone https://github.com/ridwanulhoquejr/goku-cli.git
cd goku-cli
go build -o goku ./cmdOr install directly:
go install github.com/ridwanulhoquejr/goku-cli/cmd@latestThe database connection string is read from GOKU_DB_URL. If unset, it defaults to:
postgres://postgres:postgres@localhost:5432/goku?sslmode=disable
Example .env:
GOKU_DB_URL=postgres://postgres:postgres@localhost:5432/goku?sslmode=disableApply the schema before using the resource commands:
goku migrate upRoll back the most recent migration:
goku migrate downThe migrations directory defaults to file://migrations. Override with --path if needed.
goku convert -i <file> -o <json|yaml> [-d <output_dir>]| Flag | Short | Description |
|---|---|---|
--input |
-i |
Path to input file (.json, .yaml, or .yml) |
--output |
-o |
Target format: json or yaml |
--dir |
-d |
Output directory (defaults to the system temp dir) |
Example:
goku convert -i example.json -o yaml -d ./outputgoku save -i <resource.json|resource.yaml>Reads the file and inserts it into resource_table as a JSONB document.
goku listPrints a table of ID, NAME, TYPE, and CREATED AT.
goku get --id <id>goku update --id <id> -i <new_file.json|new_file.yaml>goku delete --id <id>goku migrate up
goku migrate down
goku migrate up --path file://migrationsmigrations/000001_create_resource_table.up.sql:
CREATE TABLE IF NOT EXISTS resource_table (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
data JSONB NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);Given example.json:
{
"Name": "Goku CLI",
"Version": "1.0.0",
"Phase": "02",
"Description": "A command-line interface for Goku, the powerful AI assistant."
}Convert to YAML:
goku convert -i example.json -o yaml -d ./outputSave into the database:
goku save -i example.json.
├── cmd/
│ └── main.go # Entry point
├── internal/
│ ├── command/ # Cobra commands
│ │ ├── root.go
│ │ ├── convert.go
│ │ ├── save.go
│ │ ├── list.go
│ │ ├── get.go
│ │ ├── update.go
│ │ ├── delete.go
│ │ └── migrate.go
│ ├── handlers/ # Business logic
│ │ ├── convert.go
│ │ ├── save.go
│ │ ├── list.go
│ │ ├── get.go
│ │ ├── update.go
│ │ ├── delete.go
│ │ └── helpers.go
│ └── db/ # Database access & migrations
│ ├── db.go
│ └── resource.go
├── migrations/ # SQL migration files
├── example.json
├── output/
├── go.mod
└── go.sum
MIT