forked from intellectronica/ruler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_toml_options.js
More file actions
43 lines (38 loc) · 1.19 KB
/
test_toml_options.js
File metadata and controls
43 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { stringify: stringifyIarna } = require('@iarna/toml');
const TOML = require('toml');
// Test different approaches to get inline arrays vs table arrays
const testData = {
mcp: {
stdio_servers: [
{name: "test", command: "echo", args: ["hello"], env: {DEBUG: "true"}}
],
sse_servers: [],
shttp_servers: [
{url: "http://example.com"},
{url: "https://api.example.com", api_key: "key123"}
]
}
};
console.log("=== @iarna/toml output ===");
console.log(stringifyIarna(testData));
console.log("\n=== toml library doesn't have stringify, only parse ===");
// Note: The 'toml' library is a parser, not a stringifier
// Test manual construction
console.log("\n=== Manual TOML construction ===");
const manualToml = `[mcp]
stdio_servers = [
{name="test", command="echo", args=["hello"], env={DEBUG="true"}}
]
sse_servers = []
shttp_servers = [
"http://example.com",
{url="https://api.example.com", api_key="key123"}
]`;
console.log(manualToml);
console.log("\n=== Test manual TOML parsing ===");
try {
const parsed = TOML.parse(manualToml);
console.log("Parsed successfully:", JSON.stringify(parsed, null, 2));
} catch(e) {
console.log("Parse error:", e.message);
}