Skip to content

Commit 85cdc6c

Browse files
committed
feat: implement finish command for managing GitHub issues, PRs, and branches
- Added FinishCommand class to handle the finish workflow. - Implemented input parsing with support for auto-detection of issues, PRs, and branches. - Added validation logic for parsed inputs, including state checks for issues and PRs. - Integrated GitHubService for fetching issue and PR details. - Implemented logging for various stages of the command execution. - Placeholder for future workflow execution logic. Fixes #46
1 parent 7db8db1 commit 85cdc6c

File tree

5 files changed

+1668
-10
lines changed

5 files changed

+1668
-10
lines changed

src/cli.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { program } from 'commander'
22
import { logger } from './utils/logger.js'
33
import { GitWorktreeManager } from './lib/GitWorktreeManager.js'
4-
import type { StartOptions, CleanupOptions } from './types/index.js'
4+
import type { StartOptions, CleanupOptions, FinishOptions } from './types/index.js'
55
import { readFileSync } from 'fs'
66
import { fileURLToPath } from 'url'
77
import { dirname, join } from 'path'
@@ -85,14 +85,19 @@ program
8585
program
8686
.command('finish')
8787
.description('Merge work and cleanup workspace')
88-
.argument('<identifier>', 'Issue number, PR number, or branch name')
89-
.option('--force', 'Force finish even with uncommitted changes')
90-
.action((identifier: string) => {
91-
notImplemented(
92-
'finish',
93-
['GitHubService (Issue #3)', 'DatabaseManager (Issue #5)', 'WorkspaceManager (Issue #6)'],
94-
`bash/merge-and-clean.sh ${identifier}`
95-
)
88+
.argument('[identifier]', 'Issue number, PR number, or branch name (auto-detected if omitted)')
89+
.option('-f, --force', 'Skip confirmation prompts')
90+
.option('-n, --dry-run', 'Preview actions without executing')
91+
.option('--pr <number>', 'Treat input as PR number', parseFloat)
92+
.action(async (identifier: string | undefined, options: FinishOptions) => {
93+
try {
94+
const { FinishCommand } = await import('./commands/finish.js')
95+
const command = new FinishCommand()
96+
await command.execute({ identifier, options })
97+
} catch (error) {
98+
logger.error(`Failed to finish workspace: ${error instanceof Error ? error.message : 'Unknown error'}`)
99+
process.exit(1)
100+
}
96101
})
97102

98103
program

0 commit comments

Comments
 (0)