cli

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package cli implements the Coggo command-line interface.

All subcommands share a Runtime built by Setup, which opens the peer registry, the SQLite store, the auth store, the schema resolver, and the federation router, then registers a StoreHandler per peer. Type definitions previously stored as EntityTypeDefinition entities are rehydrated into the resolver so user-defined types survive restarts.

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.1.0-dev"

Version reported by `coggo version`. Overridable at build time via `-ldflags "-X github.com/lunguini/coggo/internal/cli.Version=<v>"`.

Functions

func AddPeerToRuntime

func AddPeerToRuntime(ctx context.Context, rt *Runtime, p *types.Peer, clientID string) error

AddPeerToRuntime registers a freshly created peer with the resolver and router, also persisting its seed types into the store as EntityTypeDefinition / RelationshipTypeDefinition entities so they survive restarts.

func App

func App() *cli.Command

App returns the root cli.Command. Wired with global flags (--config, --peer) and all subcommands. Running with no subcommand is `serve`.

func CreateEntity

func CreateEntity(ctx context.Context, rt *Runtime, peerDID, typ string, fields map[string]any, clientID string) (*types.Entity, error)

CreateEntity is a convenience wrapper around the entity.create op.

func CreateRelation

func CreateRelation(ctx context.Context, rt *Runtime, peerDID, from, to, typ string, data map[string]any, clientID string) (*types.Relation, error)

CreateRelation wraps relation.create.

func DefineType

func DefineType(ctx context.Context, rt *Runtime, peerDID, name, description string, fields []types.FieldDef, isRel, directional bool, clientID string) error

DefineType wraps type.define.

func FedCall

func FedCall(ctx context.Context, rt *Runtime, peerDID, msgType, op string, args any) (json.RawMessage, error)

FedCall sends a federation message to the named peer (op + args -> response payload). On error response, returns an error built from the payload.

func GetEntity

func GetEntity(ctx context.Context, rt *Runtime, peerDID, id string) (*types.Entity, error)

GetEntity wraps entity.get.

func QueryEntities

func QueryEntities(ctx context.Context, rt *Runtime, peerDID string, q types.EntityQuery) ([]*types.Entity, error)

QueryEntities wraps entity.query.

func UpdateEntity

func UpdateEntity(ctx context.Context, rt *Runtime, peerDID, id string, fields map[string]any, clientID string) (*types.Entity, error)

UpdateEntity wraps entity.update.

Types

type Runtime

type Runtime struct {
	Cfg      *config.Config
	Registry *peer.Registry
	Store    types.Store

	Auth     types.Authority
	Router   types.Router
	Resolver *schema.Resolver
	// contains filtered or unexported fields
}

Runtime bundles the substrate every CLI command needs.

func Setup

func Setup(ctx context.Context, cfg *config.Config) (*Runtime, error)

Setup opens all dependencies and wires them together. Idempotent in the sense that re-opening an existing data directory rehydrates state from disk.

func (*Runtime) Close

func (r *Runtime) Close() error

Close releases the store.

Jump to

Keyboard shortcuts

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