cligen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: CC0-1.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cligen generates cobra CLI commands from Java API YAML specs. It produces Go source files for cmd/jnicli that call proto-generated gRPC stubs directly, covering the full Android API surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(
	specPath string,
	overlayPath string,
	outputDir string,
	goModule string,
	protoDir string,
) error

Generate loads a Java API spec and overlay, builds proto data, converts it to CLI data structures, and writes a cobra command file. protoDir is the base directory containing compiled proto Go stubs.

Types

type CLICommand

type CLICommand struct {
	RPCName         string    // e.g., "Cancel"
	CobraName       string    // e.g., "cancel"
	VarName         string    // e.g., "Cancel" (for Go var names)
	Short           string    // cobra short description
	RequestType     string    // e.g., "CancelRequest"
	Flags           []CLIFlag // request message fields → flags
	ServerStreaming bool
	ClientStreaming bool
}

CLICommand describes a single RPC as a cobra leaf command.

type CLIFlag

type CLIFlag struct {
	CobraName  string // e.g., "carrier-frequency" (kebab-case)
	ProtoField string // e.g., "CarrierFrequency" (PascalCase, for req.Field = v)
	CobraType  string // e.g., "Int64" (for Flags().Get<Type> / Flags().<Type>)
	GoType     string // e.g., "int64"
	Default    string // e.g., "0", `""`, "false"
	ProtoType  string // e.g., "int64" (proto field Go type)
}

CLIFlag describes a cobra flag derived from a proto request field.

type CLIPackage

type CLIPackage struct {
	GoModule    string
	PackageName string       // e.g., "alarm"
	VarPrefix   string       // e.g., "alarm" (for Go var names)
	Services    []CLIService // non-streaming services
}

CLIPackage describes a single proto package's CLI commands.

type CLIService

type CLIService struct {
	ProtoServiceName string       // e.g., "ManagerService"
	CobraName        string       // e.g., "manager"
	VarName          string       // e.g., "Manager" (for Go var names)
	Short            string       // cobra short description
	Commands         []CLICommand // leaf commands
}

CLIService describes a gRPC service's CLI subcommands.

Jump to

Keyboard shortcuts

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