← All projects

geoserver-cli

Go CLI for managing a GeoServer instance over its REST API: workspaces, stores, styles, layers, coverages, PostGIS publishing, and QGIS project import.

  • Go 97.69%
  • Shell 2.31%
git@gitlab.com:aice-lab/geoserver-cli.git

Latest commit

c6cd3de5 ·

README

GeoServer-CLI

Go-based CLI for managing GeoServer via its REST API.

This repo started as a Python project and was rebuilt in Go as a learning journey. The Python code has been removed; this is now a Go-first repository.

Build

From the repo root:

go test ./...
go build -o geoserver-cli ./cmd/geoserver-cli
./geoserver-cli --help

Install repo-managed git hooks (pre-commit runs the same checks as CI):

./scripts/setup-git-hooks.sh

Install pinned dev tools (required for pre-commit golangci-lint):

./scripts/install-tools.sh

If you use direnv, add repo-local tools to PATH: PATH_add ./bin

Configuration

Config files live in configs/ and follow the convention configs/<name>.config.toml.

  • Default (committed template): configs/default.config.toml
  • Create more (ignored by git): configs/dev.config.toml, configs/prod.config.toml, etc.

You can select config in 3 ways:

  • CLI flag: -c dev or --config configs/dev.config.toml
  • Env var: GEOSRVCLI_CONFIG=dev (or a path)
  • Fallback: uses configs/default.config.toml

If you use direnv, start with:

cp .envrc.example .envrc
direnv allow

Examples

List workspaces:

./geoserver-cli workspace list

Get GeoServer default workspace:

./geoserver-cli workspace get --default

Create a datastore (workspace defaults to GEOSRVCLI_DEFAULT_WORKSPACE if set):

./geoserver-cli store create my_store -w my_workspace --params @conn.json

Create a style from an SLD file:

./geoserver-cli style create my_style --sld @mystyle.sld

Update a style from stdin:

cat mystyle.sld | ./geoserver-cli style update my_style --sld -

Publish layers from PostGIS:

# Publish all spatial tables from PostGIS
./geoserver-cli publish postgis --all -w my_workspace

# Publish specific tables
./geoserver-cli publish postgis --layers roads,buildings -w my_workspace

Export QGIS connection files:

# Generate QGIS connections XML for a workspace
./geoserver-cli qgis export connections -w my_workspace -o geoserver_connections.xml

# Generate QGIS project file with all layers
./geoserver-cli qgis export project -w my_workspace -o geoserver_layers.qgs

Note: Generated QGIS files do not include credentials by default for security. See QGIS Auth Manager Setup Guide for configuring authentication.

This is a snapshot generated from GitLab. For the live README, see the project page.