# Set default values
name := "rentease"
port := "8000"
db_user := "ruidy"
db_name := "villafleurie"

# List available recipes
default:
    @just --list

# Build the binary
build: format lint
    @docker build -t {{name}}:latest .

# Run the binary
run: build
    @docker run -p {{port}}:{{port}} \
    -e DATABASE_URL="host=docker.for.mac.host.internal user={{db_user}} database={{db_name}}" \
    -e PORT={{port}} {{name}}

# Run the binary in dev mode
dev:
    @docker build -t {{name}}:dev -f Dockerfile.dev .
    @docker run -p {{port}}:{{port}} --rm \
    -v `pwd`:/app -v /app/tmp \
    --name {{name}} \
    -e DATABASE_URL="host=docker.for.mac.host.internal user={{db_user}} database={{db_name}}" \
    -e PORT={{port}} {{name}}:dev

# Run the tests
test:
    @go test ./...

# Update dependencies
up-deps:
    @go get -u ./...

# Run the cron
cron:
    @go run cmd/cron/main.go

# Format the code
format:
    @templ generate internal/views
    @templ fmt .
    @go fmt ./...

# Lint the code
lint:
    @golangci-lint run ./...
