mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 15:24:10 +08:00
feat!: remove optional length marker option [#N] in favor of [N]
This commit is contained in:
@@ -62,7 +62,6 @@ cat data.toon | toon --decode
|
||||
| `-d, --decode` | Force decode mode (overrides auto-detection) |
|
||||
| `--delimiter <char>` | Array delimiter: `,` (comma), `\t` (tab), `\|` (pipe) |
|
||||
| `--indent <number>` | Indentation size (default: `2`) |
|
||||
| `--length-marker` | Add `#` prefix to array lengths (e.g., `items[#3]`) |
|
||||
| `--stats` | Show token count estimates and savings (encode only) |
|
||||
| `--no-strict` | Disable strict validation when decoding |
|
||||
| `--key-folding <mode>` | Enable key folding: `off`, `safe` (default: `off`) |
|
||||
@@ -122,7 +121,7 @@ cat large-dataset.json | toon --delimiter "\t" > output.toon
|
||||
jq '.results' data.json | toon > filtered.toon
|
||||
```
|
||||
|
||||
### Key Folding (spec v1.5)
|
||||
### Key Folding (Since v1.5)
|
||||
|
||||
Collapse nested wrapper chains to reduce tokens:
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ export async function encodeToToon(config: {
|
||||
output?: string
|
||||
indent: NonNullable<EncodeOptions['indent']>
|
||||
delimiter: NonNullable<EncodeOptions['delimiter']>
|
||||
lengthMarker: NonNullable<EncodeOptions['lengthMarker']>
|
||||
keyFolding?: NonNullable<EncodeOptions['keyFolding']>
|
||||
flattenDepth?: number
|
||||
printStats: boolean
|
||||
@@ -31,7 +30,6 @@ export async function encodeToToon(config: {
|
||||
const encodeOptions: EncodeOptions = {
|
||||
delimiter: config.delimiter,
|
||||
indent: config.indent,
|
||||
lengthMarker: config.lengthMarker,
|
||||
keyFolding: config.keyFolding,
|
||||
flattenDepth: config.flattenDepth,
|
||||
}
|
||||
|
||||
@@ -41,11 +41,6 @@ export const mainCommand: CommandDef<{
|
||||
description: string
|
||||
default: string
|
||||
}
|
||||
lengthMarker: {
|
||||
type: 'boolean'
|
||||
description: string
|
||||
default: false
|
||||
}
|
||||
strict: {
|
||||
type: 'boolean'
|
||||
description: string
|
||||
@@ -107,11 +102,6 @@ export const mainCommand: CommandDef<{
|
||||
description: 'Indentation size',
|
||||
default: '2',
|
||||
},
|
||||
lengthMarker: {
|
||||
type: 'boolean',
|
||||
description: 'Use length marker (#) for arrays',
|
||||
default: false,
|
||||
},
|
||||
strict: {
|
||||
type: 'boolean',
|
||||
description: 'Enable strict mode for decoding',
|
||||
@@ -187,10 +177,9 @@ export const mainCommand: CommandDef<{
|
||||
output: outputPath,
|
||||
delimiter: delimiter as Delimiter,
|
||||
indent,
|
||||
lengthMarker: args.lengthMarker === true ? '#' : false,
|
||||
printStats: args.stats === true,
|
||||
keyFolding: keyFolding as NonNullable<EncodeOptions['keyFolding']>,
|
||||
flattenDepth,
|
||||
printStats: args.stats === true,
|
||||
})
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -44,7 +44,6 @@ describe('toon CLI', () => {
|
||||
const expected = encode(data, {
|
||||
delimiter: DEFAULT_DELIMITER,
|
||||
indent: 2,
|
||||
lengthMarker: false,
|
||||
})
|
||||
|
||||
expect(output).toBe(expected)
|
||||
|
||||
Reference in New Issue
Block a user