diff --git a/package.json b/package.json index 4ae3970..6bdb862 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "version": "0.1.0", "description": "GitHub Action inteligente para transformar TODOs em issues e tarefas rastreĆ”veis.", "main": "dist/index.js", + "bin": { + "todo-action": "dist/main.js" + }, "scripts": { "build": "tsc", "test": "vitest run", diff --git a/src/main.ts b/src/main.ts index 1499309..5c6e0a3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,39 @@ -// Ponto de entrada da Action +#!/usr/bin/env node +// Simple CLI entrypoint -console.log('TODO Watcher iniciado'); \ No newline at end of file +import { extractTodosFromDir } from './parser/extractTodosFromDir'; +import { generateMarkdownReport } from './core/report'; + +interface Options { + dir: string; + report: boolean; +} + +function parseArgs(): Options { + const args = process.argv.slice(2); + const opts: Options = { dir: '.', report: false }; + + for (let i = 0; i < args.length; i++) { + const arg = args[i]; + if ((arg === '--dir' || arg === '-d') && args[i + 1]) { + opts.dir = args[++i]; + } else if (arg === '--report' || arg === '-r') { + opts.report = true; + } + } + + return opts; +} + +function run(): void { + const { dir, report } = parseArgs(); + const todos = extractTodosFromDir(dir); + console.log(`\u{1F50D} Found ${todos.length} TODOs`); + + if (report) { + generateMarkdownReport(todos); + console.log('šŸ“ Generated TODO_REPORT.md'); + } +} + +run();