chromia-cli-base is the minimal base module providing shared utilities for CLI output formatting. It contains foundational code used by other modules in the chromia-cli-tools project.
This module provides:
- JSON table formatting utilities
- Terminal output utilities (Mordant-based)
The module is structured as a thin utility layer with minimal dependencies:
chromia-cli-base/
└── src/main/kotlin/com/chromia/cli/base/
├── formatter/
│ └── json.kt # JSON table formatting
└── mordant/
└── mordant.kt # Terminal output utilities
json.kt:
jsonTable(): Converts table structures to JSON formatjson(): Pretty-prints JSON data using GsonfixKey(): Normalizes keys for JSON output (replaces spaces with underscores, removes colons)
Purpose: Provides utilities for formatting CLI output as JSON tables, enabling structured data output for programmatic consumption.
mordant.kt:
- Internal utilities copied from the Mordant library (terminal output library)
TableBuilderInstance: Internal table builder implementationCellStyleBuilderMixin: Cell styling utilitiesColumnBuilderInstance: Column configuration utilities
Core Dependencies:
net.postchain:postchain-common- Postchain common utilitiesnet.postchain.client:postchain-client- Postchain client librarycom.github.ajalt.clikt:clikt-jvm- CLI frameworkcom.github.ajalt.mordant:mordant-jvm-jna-jvm- Terminal output formattingio.github.microutils:kotlin-logging-jvm- Logging utilitiescom.google.code.gson:gson- JSON processing
This module is primarily consumed by chromia-cli-tools module for CLI output formatting. It provides low-level utilities that other modules build upon.
Example Usage (from chromia-cli-tools):
import com.chromia.cli.base.formatter.json
import com.chromia.cli.base.formatter.jsonTable
// Format data as JSON
val jsonOutput = json(data)
// Format table as JSON
val tableJson = jsonTable {
header { /* ... */ }
body { /* ... */ }
}The build ensures that the binary compatibility of this library is maintained. If you make any changes to the exported API, run:
mvn compile kotlin-bcv:dumpThis updates the binary compatibility baseline.
- Minimal Functionality: This module is intentionally minimal. Most functionality is in
chromia-cli-toolsandchromia-build-toolsmodules.