Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .beads/issues.jsonl

This file was deleted.

17 changes: 6 additions & 11 deletions feature_list.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
[
{
"name": "Tag filtering endpoint",
"description": "GET /api/notes?tag=work returns only notes with that tag. Already partially implemented — needs tests.",
"name": "Add --version flag",
"description": "Add --version and -v flags",
"passes": false
},
{
"name": "Full-text search",
"description": "GET /api/notes?q=meeting searches title and content. Already partially implemented — needs edge case tests (empty query, no matches).",
"name": "Implement help command",
"description": "Implement help subcommand and flags",
"passes": false
},
{
"name": "Pagination support",
"description": "GET /api/notes?page=1&limit=10 returns paginated results with total count in response. Add pagination metadata: { data: [...], total: N, page: N, limit: N }.",
"passes": false
},
{
"name": "Note archiving",
"description": "Add an 'archived' boolean field to notes. POST /api/notes/:id/archive and /api/notes/:id/unarchive endpoints. GET /api/notes excludes archived notes by default; GET /api/notes?include_archived=true includes them.",
"name": "Add input validation",
"description": "Validate empty or blank strings",
"passes": false
}
]
32 changes: 0 additions & 32 deletions plan.md

This file was deleted.

27 changes: 27 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
const args = process.argv.slice(2);
for (const arg of args) {
if (arg.trim() === '') {
console.error('Error: Invalid argument. Arguments cannot be empty or whitespace-only.');
process.exit(1);
}
}

if (process.argv.includes('--version') || process.argv.includes('-v')) {
console.log('fleet-e2e-toy v1.0.0');
process.exit(0);
}

const helpMessage = `Usage: fleet-e2e-toy [command] [options]

Commands:
help Display help information

Options:
-v, --version Display version information
-h, --help Display help information`;

if (process.argv.includes('help') || process.argv.includes('--help') || process.argv.includes('-h')) {
console.log(helpMessage);
process.exit(0);
}

import app from "./app";

const PORT = process.env.PORT ?? 3000;
Expand Down
57 changes: 57 additions & 0 deletions tests/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { execSync } from 'child_process';
import path from 'path';

const tsNode = path.resolve(__dirname, '../node_modules/.bin/ts-node');
const entryPoint = path.resolve(__dirname, '../src/index.ts');

describe('CLI --version', () => {
it('prints the correct version and exits 0', () => {
const output = execSync(`"${tsNode}" "${entryPoint}" --version`, { encoding: 'utf8', env: { ...process.env, PORT: '0' } });
expect(output.trim()).toBe('fleet-e2e-toy v1.0.0');
});

it('prints the correct version with -v and exits 0', () => {
const output = execSync(`"${tsNode}" "${entryPoint}" -v`, { encoding: 'utf8', env: { ...process.env, PORT: '0' } });
expect(output.trim()).toBe('fleet-e2e-toy v1.0.0');
});
});

describe('CLI help', () => {
const expectedHelp = `Usage: fleet-e2e-toy [command] [options]

Commands:
help Display help information

Options:
-v, --version Display version information
-h, --help Display help information`;

it('prints help information with --help', () => {
const output = execSync(`"${tsNode}" "${entryPoint}" --help`, { encoding: 'utf8', env: { ...process.env, PORT: '0' } });
expect(output.trim()).toBe(expectedHelp);
});

it('prints help information with -h', () => {
const output = execSync(`"${tsNode}" "${entryPoint}" -h`, { encoding: 'utf8', env: { ...process.env, PORT: '0' } });
expect(output.trim()).toBe(expectedHelp);
});

it('prints help information with help subcommand', () => {
const output = execSync(`"${tsNode}" "${entryPoint}" help`, { encoding: 'utf8', env: { ...process.env, PORT: '0' } });
expect(output.trim()).toBe(expectedHelp);
});
});

describe('CLI input validation', () => {
it('rejects empty string argument', () => {
expect(() => {
execSync(`"${tsNode}" "${entryPoint}" ""`, { encoding: 'utf8', env: { ...process.env, PORT: '0' }, stdio: 'pipe' });
}).toThrow();
});

it('rejects whitespace-only string argument', () => {
expect(() => {
execSync(`"${tsNode}" "${entryPoint}" " "`, { encoding: 'utf8', env: { ...process.env, PORT: '0' }, stdio: 'pipe' });
}).toThrow();
});
});
Loading