Skip to content

Commit 698b134

Browse files
Merge pull request #176 from DiogoRibeiro7/codex/update-cli-parsing-and-bin-field
Add CLI entrypoint
2 parents 807c41b + 8f446e3 commit 698b134

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "0.1.0",
44
"description": "GitHub Action inteligente para transformar TODOs em issues e tarefas rastreáveis.",
55
"main": "dist/index.js",
6+
"bin": {
7+
"todo-action": "dist/main.js"
8+
},
69
"scripts": {
710
"build": "tsc",
811
"test": "vitest run",

src/main.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1-
// Ponto de entrada da Action
1+
#!/usr/bin/env node
2+
// Simple CLI entrypoint
23

3-
console.log('TODO Watcher iniciado');
4+
import { extractTodosFromDir } from './parser/extractTodosFromDir';
5+
import { generateMarkdownReport } from './core/report';
6+
7+
interface Options {
8+
dir: string;
9+
report: boolean;
10+
}
11+
12+
function parseArgs(): Options {
13+
const args = process.argv.slice(2);
14+
const opts: Options = { dir: '.', report: false };
15+
16+
for (let i = 0; i < args.length; i++) {
17+
const arg = args[i];
18+
if ((arg === '--dir' || arg === '-d') && args[i + 1]) {
19+
opts.dir = args[++i];
20+
} else if (arg === '--report' || arg === '-r') {
21+
opts.report = true;
22+
}
23+
}
24+
25+
return opts;
26+
}
27+
28+
function run(): void {
29+
const { dir, report } = parseArgs();
30+
const todos = extractTodosFromDir(dir);
31+
console.log(`\u{1F50D} Found ${todos.length} TODOs`);
32+
33+
if (report) {
34+
generateMarkdownReport(todos);
35+
console.log('📝 Generated TODO_REPORT.md');
36+
}
37+
}
38+
39+
run();

0 commit comments

Comments
 (0)