cli-go

module
v0.0.0-...-9833379 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: AGPL-3.0

README

Polis Go CLI

Go implementation of the Polis CLI, providing the same features as the bash CLI with the added benefit of importable packages for the webapp.

Building

Prerequisites: Go 1.21+

# Development build
go build ./cmd/polis

# Run
./polis render --force
./polis version

Distribution Builds

# Linux (amd64)
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o polis-linux-amd64 ./cmd/polis

# macOS (Apple Silicon)
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o polis-darwin-arm64 ./cmd/polis

# macOS (Intel)
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o polis-darwin-amd64 ./cmd/polis

# Windows
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o polis-windows-amd64.exe ./cmd/polis

Package Structure

Core packages in pkg/ are designed to be imported by other Go applications:

Package Description
pkg/render Markdown to HTML conversion and page rendering
pkg/template Mustache-like template engine
pkg/theme Theme template loading
pkg/signing Ed25519 cryptographic signing
pkg/publish Post publishing logic
pkg/comment Comment management
pkg/blessing Blessing workflow
pkg/discovery Discovery service HTTP client
pkg/snippet Snippet file management
pkg/metadata Public index (JSONL) management
pkg/site Site validation and initialization
pkg/hooks Post-action automation
pkg/url URL normalization utilities

Usage as Library

import (
    "github.com/vdibart/polis-cli/cli-go/pkg/render"
    "github.com/vdibart/polis-cli/cli-go/pkg/publish"
)

// Render all pages
renderer, _ := render.NewPageRenderer(render.PageConfig{
    DataDir:       "/path/to/site",
    CLIThemesDir:  "/path/to/themes",
    BaseURL:       "https://example.com",
    RenderMarkers: false,
})
stats, _ := renderer.RenderAll(true)

// Publish a post
result, _ := publish.PublishPost(dataDir, content, filename, privateKey)

Commands

The Go CLI implements all Polis commands (init, post, comment, render, blessing, follow, clone, migrate, etc.). See the CLI Command Reference for the full list.

Template System

The Go CLI implements the same Mustache-like template syntax as the bash CLI:

  • {{variable}} - Variable substitution
  • {{> snippet}} - Partial includes (global-first by default)
  • {{> theme:snippet}} - Theme-first lookup
  • {{#section}}...{{/section}} - Loop blocks

Resolution order for snippets without explicit extension: .md.html → exact

Testing

# Run all tests
go test ./...

# Run tests with verbose output
go test -v ./...

# Run specific package tests
go test -v ./pkg/render/...

Centralized Documentation

For comprehensive CLI documentation, see docs/cli/:

Directories

Path Synopsis
cmd
polis command
polis is the Go CLI for the Polis decentralized social network.
polis is the Go CLI for the Polis decentralized social network.
pkg
atomicfile
Package atomicfile provides atomic file writes via temp+rename.
Package atomicfile provides atomic file writes via temp+rename.
blessing
Package blessing provides blessing workflow management for polis.
Package blessing provides blessing workflow management for polis.
bundle
Package bundle provides types and loading for polis bundles.
Package bundle provides types and loading for polis bundles.
cache
Package cache holds isolated, non-canonical local mirrors of foreign content.
Package cache holds isolated, non-canonical local mirrors of foreign content.
clone
Package clone provides functionality to clone remote polis sites.
Package clone provides functionality to clone remote polis sites.
cmd
Package cmd provides the CLI command handlers for the polis CLI.
Package cmd provides the CLI command handlers for the polis CLI.
comment
Package comment provides comment management for polis.
Package comment provides comment management for polis.
discovery
Package discovery provides a client for the polis discovery service.
Package discovery provides a client for the polis discovery service.
dm
Package dm implements encrypted direct messaging between polis instances.
Package dm implements encrypted direct messaging between polis instances.
feed
Package feed provides feed management for followed authors.
Package feed provides feed management for followed authors.
following
Package following manages the following.json file for tracking followed authors.
Package following manages the following.json file for tracking followed authors.
hooks
Package hooks provides post-action automation for polis events.
Package hooks provides post-action automation for polis events.
httppool
Package httppool provides a shared HTTP transport for connection pooling across all outbound HTTP clients in the polis system.
Package httppool provides a shared HTTP transport for connection pooling across all outbound HTTP clients in the polis system.
index
Package index provides index rebuilding functionality.
Package index provides index rebuilding functionality.
metadata
Package metadata provides management for polis public metadata files.
Package metadata provides management for polis public metadata files.
notification
Package notification manages the notification state layer.
Package notification manages the notification state layer.
ops
Package ops provides a content-type dispatch engine for polis.
Package ops provides a content-type dispatch engine for polis.
policy
Package policy provides a declarative rule system for controlling which content and events are accepted by a polis site.
Package policy provides a declarative rule system for controlling which content and events are accepted by a polis site.
policycheck
Package policycheck provides reusable remote policy evaluation.
Package policycheck provides reusable remote policy evaluation.
pql
Package pql parses PQL (Polis Query Language) sentences into a filter state struct, and composes them back.
Package pql parses PQL (Polis Query Language) sentences into a filter state struct, and composes them back.
publish
Package publish provides post publishing logic compatible with the polis CLI.
Package publish provides post publishing logic compatible with the polis CLI.
remote
Package remote provides HTTP fetching and .well-known retrieval for remote polis sites.
Package remote provides HTTP fetching and .well-known retrieval for remote polis sites.
render
Package render provides markdown to HTML rendering using goldmark.
Package render provides markdown to HTML rendering using goldmark.
resolve
Package resolve provides centralized path resolution for polis sites.
Package resolve provides centralized path resolution for polis sites.
signing
Package signing provides Ed25519 key generation, SSH signature format signing, and Ed25519↔X25519 key conversion for encryption.
Package signing provides Ed25519 key generation, SSH signature format signing, and Ed25519↔X25519 key conversion for encryption.
site
Package site provides CLI-compatible polis site operations.
Package site provides CLI-compatible polis site operations.
sitemap
Package sitemap builds and incrementally updates the tenant's sitemap.xml per the sitemaps.org 0.9 schema.
Package sitemap builds and incrementally updates the tenant's sitemap.xml per the sitemaps.org 0.9 schema.
snippet
Package snippet provides management for polis snippet files.
Package snippet provides management for polis snippet files.
stream
Package stream manages per-projection cursors, state, and config on disk.
Package stream manages per-projection cursors, state, and config on disk.
tag
Package tag manages tag files for the pub.polis.tag content type.
Package tag manages tag files for the pub.polis.tag content type.
tailor
Package tailor diagnoses and auto-fixes polis sites to bring them up to current spec.
Package tailor diagnoses and auto-fixes polis sites to bring them up to current spec.
template
Package template provides a Mustache-like template engine for polis themes.
Package template provides a Mustache-like template engine for polis themes.
theme
Package theme provides theme loading and management for polis.
Package theme provides theme loading and management for polis.
url
Package url provides URL utilities for polis.
Package url provides URL utilities for polis.
verify
Package verify provides remote signature verification for polis content.
Package verify provides remote signature verification for polis content.
version
Package version provides version history parsing and reconstruction.
Package version provides version history parsing and reconstruction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL