test(cli): add basic test suite

This commit is contained in:
Johann Schopplich
2025-11-04 07:45:50 +01:00
parent 8f0156c1af
commit af298537a4
6 changed files with 262 additions and 6 deletions

View File

@@ -0,0 +1,4 @@
import { runMain } from 'citty'
import { mainCommand } from '.'
runMain(mainCommand)

View File

@@ -1,15 +1,62 @@
import type { CommandDef } from 'citty'
import type { Delimiter } from '../../toon/src'
import type { InputSource } from './types'
import * as path from 'node:path'
import process from 'node:process'
import { defineCommand, runMain } from 'citty'
import { defineCommand } from 'citty'
import { consola } from 'consola'
import { name, version } from '../../toon/package.json' with { type: 'json' }
import { DEFAULT_DELIMITER, DELIMITERS } from '../../toon/src'
import { decodeToJson, encodeToToon } from './conversion'
import { detectMode } from './utils'
const main = defineCommand({
export const mainCommand: CommandDef<{
input: {
type: 'positional'
description: string
required: false
}
output: {
type: 'string'
description: string
alias: string
}
encode: {
type: 'boolean'
description: string
alias: string
}
decode: {
type: 'boolean'
description: string
alias: string
}
delimiter: {
type: 'string'
description: string
default: string
}
indent: {
type: 'string'
description: string
default: string
}
lengthMarker: {
type: 'boolean'
description: string
default: false
}
strict: {
type: 'boolean'
description: string
default: true
}
stats: {
type: 'boolean'
description: string
default: false
}
}> = defineCommand({
meta: {
name,
description: 'TOON CLI — Convert between JSON and TOON formats',
@@ -110,5 +157,3 @@ const main = defineCommand({
}
},
})
runMain(main)