refactor: use --json flag alias instead of --format json throughout CLI

This commit is contained in:
Mohamed Boudra
2026-02-01 12:33:18 +07:00
parent dac1538d1f
commit a473302a9f
22 changed files with 313 additions and 167 deletions
+7 -7
View File
@@ -9,7 +9,7 @@
* Tests:
* - daemon --help shows subcommands
* - daemon status fails gracefully when daemon not running
* - daemon status --format json outputs valid JSON (even for errors)
* - daemon status --json outputs valid JSON (even for errors)
* - daemon stop handles daemon not running gracefully
*/
@@ -56,11 +56,11 @@ try {
console.log('✓ daemon status fails gracefully when not running\n')
}
// Test 3: daemon status --format json outputs valid JSON (even for errors)
// Test 3: daemon status --json outputs valid JSON (even for errors)
{
console.log('Test 3: daemon status --format json outputs JSON')
console.log('Test 3: daemon status --json outputs JSON')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo daemon status --format json`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo daemon status --json`.nothrow()
// Should still fail (daemon not running)
assert.notStrictEqual(result.exitCode, 0, 'should fail when daemon not running')
// But output should be valid JSON
@@ -68,14 +68,14 @@ try {
if (output.length > 0) {
try {
JSON.parse(output)
console.log('✓ daemon status --format json outputs valid JSON\n')
console.log('✓ daemon status --json outputs valid JSON\n')
} catch {
// If stdout is empty, check if stderr has the error (acceptable for now)
console.log('✓ daemon status --format json handled error (output may be in stderr)\n')
console.log('✓ daemon status --json handled error (output may be in stderr)\n')
}
} else {
// Empty stdout is acceptable if error is in stderr
console.log('✓ daemon status --format json handled error gracefully\n')
console.log('✓ daemon status --json handled error gracefully\n')
}
}
+7 -7
View File
@@ -13,7 +13,7 @@
* - paseo --help shows ls command
* - paseo ls --help shows options
* - paseo ls returns empty list or error when no daemon
* - paseo ls --format json returns valid JSON (or error)
* - paseo ls --json returns valid JSON (or error)
* - paseo ls -a flag is accepted
* - paseo ls -g flag is accepted
*/
@@ -71,11 +71,11 @@ try {
console.log('✓ paseo ls handles daemon not running\n')
}
// Test 4: paseo ls --format json returns valid JSON error
// Test 4: paseo ls --json returns valid JSON error
{
console.log('Test 4: paseo ls --format json handles errors')
console.log('Test 4: paseo ls --json handles errors')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo ls --format json`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo ls --json`.nothrow()
// Should still fail (daemon not running)
assert.notStrictEqual(result.exitCode, 0, 'should fail when daemon not running')
// But output should be valid JSON if present
@@ -83,13 +83,13 @@ try {
if (output.length > 0) {
try {
JSON.parse(output)
console.log('✓ paseo ls --format json outputs valid JSON error\n')
console.log('✓ paseo ls --json outputs valid JSON error\n')
} catch {
// Empty or stderr-only output is acceptable
console.log('✓ paseo ls --format json handled error (output may be in stderr)\n')
console.log('✓ paseo ls --json handled error (output may be in stderr)\n')
}
} else {
console.log('✓ paseo ls --format json handled error gracefully\n')
console.log('✓ paseo ls --json handled error gracefully\n')
}
}
+5 -5
View File
@@ -98,15 +98,15 @@ try {
console.log('-q (quiet) flag is accepted with inspect\n')
}
// Test 6: --format json flag is accepted with inspect
// Test 6: --json flag is accepted with inspect
{
console.log('Test 6: --format json flag is accepted with inspect')
console.log('Test 6: --json flag is accepted with inspect')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo --format json inspect abc123`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo inspect abc123 --json`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept --format json flag')
assert(!output.includes('unknown option'), 'should accept --json flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('--format json flag is accepted with inspect\n')
console.log('--json flag is accepted with inspect\n')
}
// Test 7: --format yaml flag is accepted with inspect
+5 -5
View File
@@ -112,15 +112,15 @@ try {
console.log('-q (quiet) flag is accepted with wait\n')
}
// Test 7: --format json flag is accepted with wait
// Test 7: --json flag is accepted with wait
{
console.log('Test 7: --format json flag is accepted with wait')
console.log('Test 7: --json flag is accepted with wait')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo --format json wait abc123`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo wait abc123 --json`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept --format json flag')
assert(!output.includes('unknown option'), 'should accept --json flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('--format json flag is accepted with wait\n')
console.log('--json flag is accepted with wait\n')
}
// Test 8: --format yaml flag is accepted with wait
+7 -7
View File
@@ -13,7 +13,7 @@
* - permit --help shows subcommands
* - permit ls --help shows options
* - permit ls returns error when no daemon
* - permit ls --format json handles errors
* - permit ls --json handles errors
*/
import assert from 'node:assert'
@@ -67,11 +67,11 @@ try {
console.log('✓ permit ls handles daemon not running\n')
}
// Test 4: permit ls --format json handles errors
// Test 4: permit ls --json handles errors
{
console.log('Test 4: permit ls --format json handles errors')
console.log('Test 4: permit ls --json handles errors')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo permit ls --format json`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo permit ls --json`.nothrow()
// Should still fail (daemon not running)
assert.notStrictEqual(result.exitCode, 0, 'should fail when daemon not running')
// But output should be valid JSON if present
@@ -79,13 +79,13 @@ try {
if (output.length > 0) {
try {
JSON.parse(output)
console.log('✓ permit ls --format json outputs valid JSON error\n')
console.log('✓ permit ls --json outputs valid JSON error\n')
} catch {
// Empty or stderr-only output is acceptable
console.log('✓ permit ls --format json handled error (output may be in stderr)\n')
console.log('✓ permit ls --json handled error (output may be in stderr)\n')
}
} else {
console.log('✓ permit ls --format json handled error gracefully\n')
console.log('✓ permit ls --json handled error gracefully\n')
}
}
+5 -5
View File
@@ -142,15 +142,15 @@ try {
console.log('✓ -q (quiet) flag is accepted with worktree ls\n')
}
// Test 10: -f json flag is accepted with worktree ls
// Test 10: --json flag is accepted with worktree ls
{
console.log('Test 10: -f json flag is accepted with worktree ls')
console.log('Test 10: --json flag is accepted with worktree ls')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo -f json worktree ls`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo worktree ls --json`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept -f json flag')
assert(!output.includes('unknown option'), 'should accept --json flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ -f json flag is accepted with worktree ls\n')
console.log('✓ --json flag is accepted with worktree ls\n')
}
// Test 11: paseo --help shows worktree subcommand
+10 -10
View File
@@ -9,13 +9,13 @@
* Tests:
* - provider --help shows subcommands
* - provider ls lists all providers
* - provider ls --format json outputs valid JSON
* - provider ls --json outputs valid JSON
* - provider ls --quiet outputs provider names only
* - provider models claude lists claude models
* - provider models codex lists codex models
* - provider models opencode lists opencode models
* - provider models unknown fails with error
* - provider models --format json outputs valid JSON
* - provider models --json outputs valid JSON
*/
import assert from 'node:assert'
@@ -47,10 +47,10 @@ console.log('=== Provider Commands ===\n')
console.log('✓ provider ls lists all providers\n')
}
// Test 3: provider ls --format json outputs valid JSON
// Test 3: provider ls --json outputs valid JSON
{
console.log('Test 3: provider ls --format json outputs valid JSON')
const result = await $`npx paseo provider ls --format json`.nothrow()
console.log('Test 3: provider ls --json outputs valid JSON')
const result = await $`npx paseo provider ls --json`.nothrow()
assert.strictEqual(result.exitCode, 0, 'should exit 0')
const data = JSON.parse(result.stdout.trim())
assert(Array.isArray(data), 'output should be an array')
@@ -58,7 +58,7 @@ console.log('=== Provider Commands ===\n')
assert(data.some((p: { provider: string }) => p.provider === 'claude'), 'should include claude')
assert(data.some((p: { provider: string }) => p.provider === 'codex'), 'should include codex')
assert(data.some((p: { provider: string }) => p.provider === 'opencode'), 'should include opencode')
console.log('✓ provider ls --format json outputs valid JSON\n')
console.log('✓ provider ls --json outputs valid JSON\n')
}
// Test 4: provider ls --quiet outputs provider names only
@@ -119,16 +119,16 @@ console.log('=== Provider Commands ===\n')
console.log('✓ provider models unknown fails with error\n')
}
// Test 9: provider models --format json outputs valid JSON
// Test 9: provider models --json outputs valid JSON
{
console.log('Test 9: provider models --format json outputs valid JSON')
const result = await $`npx paseo provider models claude --format json`.nothrow()
console.log('Test 9: provider models --json outputs valid JSON')
const result = await $`npx paseo provider models claude --json`.nothrow()
assert.strictEqual(result.exitCode, 0, 'should exit 0')
const data = JSON.parse(result.stdout.trim())
assert(Array.isArray(data), 'output should be an array')
assert.strictEqual(data.length, 3, 'should have 3 models for claude')
assert(data.every((m: { model: string; id: string }) => m.model && m.id), 'each model should have name and id')
console.log('✓ provider models --format json outputs valid JSON\n')
console.log('✓ provider models --json outputs valid JSON\n')
}
// Test 10: provider models --quiet outputs model IDs only
@@ -60,7 +60,7 @@ async function cleanup(): Promise<void> {
async function test_agent_ls_empty(): Promise<void> {
console.log('\n--- Test: agent ls with empty list ---')
const result = await ctx.paseo(['ls', '--format', 'json'])
const result = await ctx.paseo(['ls', '--json'])
console.log('Exit code:', result.exitCode)
console.log('Stdout:', result.stdout)
@@ -116,7 +116,7 @@ async function test_agent_run_detached(): Promise<string> {
async function test_agent_ls_shows_agent(agentId: string): Promise<void> {
console.log('\n--- Test: agent ls shows created agent ---')
const result = await ctx.paseo(['ls', '--format', 'json'])
const result = await ctx.paseo(['ls', '--json'])
console.log('Exit code:', result.exitCode)
console.log('Stdout:', result.stdout)
@@ -198,7 +198,7 @@ async function test_agent_stop(agentId: string): Promise<void> {
assert.strictEqual(result.exitCode, 0, 'agent stop should succeed')
// Verify agent is no longer in running list
const psResult = await ctx.paseo(['ls', '--format', 'json'])
const psResult = await ctx.paseo(['ls', '--json'])
const agents = JSON.parse(psResult.stdout.trim()) as Array<{ id: string; status?: string }>
// Agent might still be in list but should not be running
+2 -2
View File
@@ -107,7 +107,7 @@ async function test_wait_for_permission_request(agentId: string): Promise<void>
const startTime = Date.now()
while (Date.now() - startTime < maxWait) {
const result = await ctx.paseo(['permit', 'ls', '--format', 'json'])
const result = await ctx.paseo(['permit', 'ls', '--json'])
if (result.exitCode === 0) {
try {
@@ -148,7 +148,7 @@ async function test_wait_for_permission_request(agentId: string): Promise<void>
async function test_permit_ls(): Promise<{ agentShortId: string; requestId: string }> {
console.log('\n--- Test: List pending permissions with permit ls ---')
const result = await ctx.paseo(['permit', 'ls', '--format', 'json'])
const result = await ctx.paseo(['permit', 'ls', '--json'])
console.log('Exit code:', result.exitCode)
console.log('Stdout:', result.stdout)