Skip to content

Commit

Permalink
chore(cli): display help for invalid args (promptfoo#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
mldangelo authored Nov 22, 2024
1 parent 4426dc8 commit c9f65a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { listCommand } from './commands/list';
import { shareCommand } from './commands/share';
import { showCommand } from './commands/show';
import { viewCommand } from './commands/view';
import logger from './logger';
import { runDbMigrations } from './migrate';
import { redteamGenerateCommand } from './redteam/commands/generate';
import { initCommand as redteamInitCommand } from './redteam/commands/init';
Expand All @@ -33,7 +34,15 @@ async function main() {
const { defaultConfig, defaultConfigPath } = await loadDefaultConfig();

const program = new Command('promptfoo');
program.version(version);
program
.version(version)
.showHelpAfterError()
.showSuggestionAfterError()
.on('option:*', function () {
logger.error('Invalid option(s)');
program.help();
process.exitCode = 1;
});

// Main commands
evalCommand(program, defaultConfig, defaultConfigPath);
Expand Down

0 comments on commit c9f65a8

Please sign in to comment.