@@ -593,6 +593,30 @@ func TestConvertOsArgs(t *testing.T) {
593593 }
594594}
595595
596+ func TestPreprocessHelpFlags (t * testing.T ) {
597+ type test struct {
598+ name string
599+ in []string
600+ expected []string
601+ }
602+
603+ tests := []test {
604+ {"empty args" , []string {}, []string {}},
605+ {"-help to --help" , []string {"-help" }, []string {"--help" }},
606+ {"-h alone to -?" , []string {"-h" }, []string {"-?" }},
607+ {"-h with number stays" , []string {"-h" , "5" }, []string {"-h" , "5" }},
608+ {"-h with flag becomes -?" , []string {"-h" , "-S" }, []string {"-?" , "-S" }},
609+ {"mixed args" , []string {"-S" , "server" , "-h" , "-Q" , "select 1" }, []string {"-S" , "server" , "-?" , "-Q" , "select 1" }},
610+ {"preserve -h N in context" , []string {"-S" , "srv" , "-h" , "10" , "-Q" , "x" }, []string {"-S" , "srv" , "-h" , "10" , "-Q" , "x" }},
611+ }
612+ for _ , c := range tests {
613+ t .Run (c .name , func (t * testing.T ) {
614+ actual := preprocessHelpFlags (c .in )
615+ assert .Equal (t , c .expected , actual , "Incorrect preprocessed args" )
616+ })
617+ }
618+ }
619+
596620func TestEncryptionOptions (t * testing.T ) {
597621 type test struct {
598622 input string
0 commit comments