Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Merged
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
12 changes: 7 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ export async function main(argv: string[]): Promise<void> {
try {
await program.parseAsync(argv)
} catch (err) {
if (
err instanceof CommanderError &&
(err.code === 'commander.helpDisplayed' || err.code === 'commander.version')
) {
return
if (err instanceof CommanderError) {
if (err.code === 'commander.helpDisplayed' || err.code === 'commander.version') {
return
}

console.error(err.message)
process.exit(err.exitCode || 1)
}

if (err instanceof ShpeckError || err instanceof GitError) {
Expand Down
12 changes: 12 additions & 0 deletions test/cli-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ describe('cli smoke', () => {
expect(stdout).toContain('Usage: shpeck')
})

it('does not print stack trace when no args', async () => {
const { exitCode, stdout, stderr } = await runCommand(['bun', cliPath], {
cwd: repoRoot,
allowNonZeroExit: true,
})

expect(exitCode).toBeGreaterThan(0)
expect(stderr).toContain('Usage: shpeck')
expect(stderr).not.toContain('Error:')
expect(stderr).not.toContain('at ')
})

it('fails on unknown command', async () => {
const { exitCode, stderr } = await runCommand(['bun', cliPath, 'nope'], {
cwd: repoRoot,
Expand Down