commit-analyzer
Version:
Analyze git commits and generate categories, summaries, and descriptions for each commit. Optionally generate a yearly breakdown report of your commit history.
64 lines (53 loc) • 1.76 kB
text/typescript
import { ApplicationError } from "@domain/application-error"
import { ConsoleFormatter } from "@presentation/console-formatter"
import { DIContainer } from "./di"
async function main(): Promise<void> {
try {
// Extract options from command line args before creating container
const llmOption = extractLLMOption(process.argv)
const noCacheOption = extractNoCacheOption(process.argv)
const container = new DIContainer({
llm: llmOption,
noCache: noCacheOption
})
const app = container.getApplication()
await app.run(process.argv)
} catch (error) {
if (error instanceof ApplicationError) {
ConsoleFormatter.logError(`[${error.code}]: ${error.message}`)
process.exit(1)
}
if (error instanceof Error) {
ConsoleFormatter.logError(`Unexpected error: ${error.message}`)
process.exit(1)
}
ConsoleFormatter.logError("Unknown error occurred")
process.exit(1)
}
}
/**
* Extract the --llm option from command line arguments
* This is needed before creating the DI container
*/
function extractLLMOption(args: string[]): string | undefined {
const llmIndex = args.findIndex(arg => arg === '--llm')
if (llmIndex !== -1 && llmIndex + 1 < args.length) {
return args[llmIndex + 1]
}
return undefined
}
/**
* Extract the --no-cache option from command line arguments
* This is needed before creating the DI container
*/
function extractNoCacheOption(args: string[]): boolean {
return args.includes('--no-cache')
}
// Run the application if this file is executed directly
if (require.main === module) {
main().catch((error) => {
ConsoleFormatter.logError(`Failed to bootstrap application: ${error}`)
process.exit(1)
})
}