chore(release): prepare public source release

This commit is contained in:
MercuryToolbox Release
2026-07-18 15:41:59 +08:00
commit e365e5df4d
508 changed files with 163373 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
[package]
name = "toon"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
readme.workspace = true
publish.workspace = true
description = "Convert between JSON and TOON text with compact CLI output."
keywords.workspace = true
categories.workspace = true
[lints]
workspace = true
[dependencies]
common = { path = "../common", default-features = false }
lexopt.workspace = true
serde.workspace = true
serde_json = { workspace = true, features = ["preserve_order"] }
[dev-dependencies]
assert_cmd.workspace = true
predicates.workspace = true
tempfile.workspace = true
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
//! Binary entry point for `toon`.
fn main() {
std::process::exit(toon::main_entry());
}
+60
View File
@@ -0,0 +1,60 @@
//! Integration coverage for the shared TOON core exposed by `common`.
use common::formats::toon::{DecodeOptions, Delimiter, EncodeOptions, SafeMode};
use serde_json::json;
#[test]
fn common_toon_encoder_handles_nested_and_tabular_values() {
let rendered = common::formats::toon::encode_value(
&json!({
"context": {
"task": "Shared TOON core",
"location": "common",
},
"items": [
{"id": 1, "name": "Ada"},
{"id": 2, "name": "Bob"},
],
}),
EncodeOptions {
indent: 2,
delimiter: Delimiter::Comma,
key_folding: SafeMode::Off,
flatten_depth: usize::MAX,
},
)
.expect("encode");
assert_eq!(
rendered,
"context:\n task: \"Shared TOON core\"\n location: common\nitems[2]{id,name}:\n 1,Ada\n 2,Bob"
);
}
#[test]
fn common_toon_decoder_handles_tabular_values_and_path_expansion() {
let decoded = common::formats::toon::decode_str(
"data.metadata.items[2]: a,b\nrows[2]{id,name}:\n 1,Ada\n 2,Bob\n",
DecodeOptions {
indent: 2,
strict: true,
expand_paths: SafeMode::Safe,
},
)
.expect("decode should succeed");
assert_eq!(
decoded,
json!({
"data": {
"metadata": {
"items": ["a", "b"],
},
},
"rows": [
{"id": 1, "name": "Ada"},
{"id": 2, "name": "Bob"},
],
})
);
}
+79
View File
@@ -0,0 +1,79 @@
//! Integration tests for the `toon` command.
use std::fs;
use assert_cmd::Command;
use predicates::prelude::*;
use tempfile::tempdir;
fn cargo_command() -> Command {
Command::cargo_bin("toon").expect("binary")
}
#[test]
fn help_includes_pipeline_examples() {
cargo_command()
.arg("--help")
.assert()
.success()
.stdout(predicate::str::contains("Convert between JSON and TOON"))
.stdout(predicate::str::contains("'{\"ok\":true}' | toon"))
.stdout(predicate::str::contains(
"bat --style=plain --paging=never .\\fixtures\\toon\\records.jsonl | toon",
))
.stdout(predicate::str::contains("toon --from json --input-format jsonl").not())
.stdout(predicate::str::contains("--expand-paths <MODE>"));
}
#[test]
fn version_prints_package_version() {
cargo_command()
.arg("--version")
.assert()
.success()
.stdout(predicate::str::contains(env!("CARGO_PKG_VERSION")));
}
#[test]
fn jsonl_stdin_converts_to_toon_table() {
cargo_command()
.write_stdin("{\"name\":\"Ada\",\"score\":10}\n{\"name\":\"Bob\",\"score\":11}\n")
.assert()
.success()
.stdout(predicate::str::contains("name,score"))
.stdout(predicate::str::contains("Ada,10"))
.stdout(predicate::str::contains("Bob,11"));
}
#[test]
fn auto_detects_jsonl_files_without_extra_flags() {
let temp = tempdir().expect("tempdir");
let path = temp.path().join("records.jsonl");
fs::write(
&path,
"{\"name\":\"Ada\",\"score\":10}\n{\"name\":\"Bob\",\"score\":11}\n",
)
.expect("fixture");
cargo_command()
.arg(&path)
.assert()
.success()
.stdout(predicate::str::contains("name,score"))
.stdout(predicate::str::contains("Ada,10"))
.stdout(predicate::str::contains("Bob,11"));
}
#[test]
fn strict_flag_accepts_false_for_loose_indent_input() {
let temp = tempdir().expect("tempdir");
let path = temp.path().join("loose.toon");
fs::write(&path, "root:\n child: value\n").expect("fixture");
cargo_command()
.args(["--from", "toon", "--to", "json", "--strict", "false"])
.arg(&path)
.assert()
.success()
.stdout(predicate::str::contains("\"child\": \"value\""));
}