Skip to content

fix: help flags preprocessing for -h and -help#707

Open
dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
dlevy-msft-sql:fix-help-flags
Open

fix: help flags preprocessing for -h and -help#707
dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
dlevy-msft-sql:fix-help-flags

Conversation

@dlevy-msft-sql
Copy link
Contributor

Problem

Users expect -h and -help to show help, but:

  • -h is interpreted as the header rows flag
  • -help is not recognized

Root Cause

The pflag library expects --help for help display, but legacy sqlcmd users may use -h or -help.

Code Change

Added preprocessHelpFlags() in cmd/sqlcmd/sqlcmd.go that:

  • Converts -help to --help
  • Converts lone -h (not followed by a number) to -?
  • Preserves -h <number> for backward-compatible header count

Testing

  • Added unit tests covering all scenarios
  • All existing tests pass

@dlevy-msft-sql dlevy-msft-sql changed the title Fix help flags preprocessing for -h and -help fix: help flags preprocessing for -h and -help Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants