zoko-cli 0.1.0

Command-line interface for the Zoko data format - parse, validate, and format .zo files
zoko-cli-0.1.0 is not a library.

Zoko

A JSON-like format for data storing

Zoko is a human-readable data format that extends JSON with additional features like comments, trailing commas, and multiple string types. It's designed for configuration files, data storage, and any use case where you need the flexibility of JSON with better readability.

Features

  • Human-Readable Syntax: Clean and intuitive syntax that's easy to read and write
  • Comments: Single-line (//) and multi-line (/* */) comments for better documentation
  • Trailing Commas: No need to worry about trailing commas - they're fully supported
  • Multiple String Types: Double-quoted, single-quoted, and multi-line backtick strings
  • JSON Compatible: Easy conversion between Zoko and JSON formats
  • Order Preservation: Maintains the original order of objects and maps using IndexMap
  • Type Safe: Full Rust API with strong typing and error handling
  • CLI Tools: Command-line interface for parsing, validation, and formatting

Installation

From Source

# Clone the repository
git clone https://github.com/akuolwa/zoko.git
cd zoko

# Build the project
cargo build --release

# The CLI binary will be available at target/release/zoko-cli

Using Cargo

cargo install zoko-cli

Add to Your Rust Project

cargo add zoko-parser

Quick Start

Create a Zoko File

Create a file named config.zo:

name: "My Application",
version: "1.0.0",
debug: true,
database: {
  host: "localhost",
  port: 5432,
},
tags: ["production", "api"],

Parse and Validate

# Validate a Zoko file
zoko-cli validate config.zo

# Parse to JSON
zoko-cli parse config.zo --output config.json

# Format a Zoko file
zoko-cli fmt config.zo

Use in Rust

use zoko_parser::{parse_zoko, parse_zoko_to_json};

fn main() {
    let zoko_content = r#"
name: "My Application",
version: "1.0.0",
debug: true,
"#;

    // Parse the Zoko content
    let zoko_file = parse_zoko(zoko_content).expect("Failed to parse Zoko");
    println!("Parsed {} entries", zoko_file.entries.len());

    // Convert to JSON
    let json = parse_zoko_to_json(zoko_content).expect("Failed to convert to JSON");
    println!("{}", json);
}

Example Zoko File

// Package metadata
name: "@Main/Hello",
channel: "main",
branch: "Production",
status: "Release",
version: "1.0.0",
description: "Hello package for Zoil",

// Tags and metadata
tags: ["Hello", "Zoil"],
website: "https://hello.nel.co",

// Dependencies with complex structures
dependencies: [
  {name: "Hola", version: "1.0.2"},
  {
    name: "@German/Hallo",
    channel: "main",
    version: "latest",
  },
],

/* Configuration block
   with detailed comments */
config: {
  debug: false,
  timeout: 30,
  retries: 3,
  servers: [
    {host: "primary.example.com", port: 8080},
    {host: "backup.example.com", port: 8080},
  ],
},

CLI Commands

# Parse and validate
zoko-cli validate config.zo
zoko-cli parse config.zo

# Format files
zoko-cli fmt config.zo
zoko-cli fmt --check config.zo

# Check syntax
zoko-cli check config.zo