pk-tools

module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0

README

pk-tools

Part of PlatformKit — the open-source Go backend for multi-tenant SaaS.

Depends on. pk-modules directly (which brings in pk-core transitively), plus cobra and golang.org/x/mod. explain imports each module package directly so the catalog it prints is sourced from the modules' own constants.

Go Reference CI

pk-tools provides the shared CLI and terminal-UI primitives for the OSS PlatformKit family: root-command assembly, JSON output helpers, context-aware command visibility, and terminal-aware status and table rendering. It deliberately ships reusable command-shell behavior only — product-specific commands live in downstream applications and compose these packages.

Install

go get github.com/septagon-oss/pk-tools@v0.1.0

Usage

package main

import (
	"github.com/septagon-oss/pk-tools/pkg/cliapp"
	"github.com/spf13/cobra"
)

func main() {
	root := cliapp.NewRoot(cliapp.RootOptions{
		Use:     "demo",
		Short:   "Demo CLI built on pk-tools primitives",
		Version: "v0.1.0",
		Commands: []*cobra.Command{
			{Use: "greet", RunE: func(cmd *cobra.Command, _ []string) error {
				cmd.Println("hello from pk-tools")
				return nil
			}},
		},
	})

	if err := cliapp.Execute(root); err != nil {
		panic(err)
	}
}

Current Surface

  • pkg/cliapp — root *cobra.Command assembly via NewRoot/RootOptions, Execute, argument helpers (HasArg, ShowAllCommands, AddHiddenBoolFlag), and JSON output helpers (WriteJSON, SortedMapKeys).
  • pkg/tui — terminal-aware Renderer with Info/Success/Warn/Error status lines, Table rendering, CommandStart banners, and a configurable Palette with NO_COLOR-aware color detection.
  • pkg/scaffold — governed code generators for modules, entities, features, and projects. Callers provide an explicit import profile and dependency graph; the generator does not emit placeholder capabilities or infer event payload schemas.
  • cmd/pk — the pk developer CLI (doctor, verify, explain modules) built on these primitives.

Try the pk CLI

go run ./cmd/pk doctor           # check that the PlatformKit OSS dev environment is healthy
go run ./cmd/pk verify           # run go vet and go test in the current Go module
go run ./cmd/pk explain modules  # print the 9-module OSS essentials pack

Verify

make verify   # go test + go vet + staticcheck + race

License

Apache-2.0. See LICENSE.

Directories

Path Synopsis
cmd
pk command
Package main implements the `pk` OSS developer CLI for PlatformKit.
Package main implements the `pk` OSS developer CLI for PlatformKit.
pkg
cliapp
Package cliapp provides composable Cobra application primitives.
Package cliapp provides composable Cobra application primitives.
tui
Package tui contains terminal-aware rendering primitives for PlatformKit CLIs.
Package tui contains terminal-aware rendering primitives for PlatformKit CLIs.

Jump to

Keyboard shortcuts

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