@@ -143,14 +143,22 @@ _${this.config.bin}() {
143143
144144 let flagSpec = ''
145145
146+ const chars = [ ]
147+ if ( f . char ) chars . push ( f . char )
148+ if ( f . charAliases ) chars . push ( ...f . charAliases )
149+ const fullNames = [ f . name , ...( f . aliases ?? [ ] ) ]
150+ const allNames = [ ...chars . map ( ( char ) => '-' + char ) , ...fullNames . map ( ( name ) => '--' + name ) ]
151+ const commaSeparated = allNames . join ( ',' )
152+ const spaceSeparated = allNames . join ( ' ' )
153+
146154 if ( f . type === 'option' ) {
147- if ( f . char ) {
155+ if ( allNames . length > 1 ) {
148156 // eslint-disable-next-line unicorn/prefer-ternary
149157 if ( f . multiple ) {
150158 // this flag can be present multiple times on the line
151- flagSpec += `"*"{- ${ f . char } ,-- ${ f . name } }`
159+ flagSpec += `"*"{${ commaSeparated } }`
152160 } else {
153- flagSpec += `"(- ${ f . char } -- ${ f . name } )"{- ${ f . char } ,-- ${ f . name } }`
161+ flagSpec += `"(${ spaceSeparated } )"{${ commaSeparated } }`
154162 }
155163
156164 flagSpec += `"[${ flagSummary } ]`
@@ -166,9 +174,9 @@ _${this.config.bin}() {
166174
167175 flagSpec += f . options ? `${ f . name } options:(${ f . options . join ( ' ' ) } )"` : 'file:_files"'
168176 }
169- } else if ( f . char ) {
177+ } else if ( allNames . length > 1 ) {
170178 // Flag.Boolean
171- flagSpec += `"(- ${ f . char } -- ${ f . name } )"{- ${ f . char } ,-- ${ f . name } }"[${ flagSummary } ]"`
179+ flagSpec += `"(${ spaceSeparated } )"{${ commaSeparated } }"[${ flagSummary } ]"`
172180 } else {
173181 // Flag.Boolean
174182 flagSpec += `--${ f . name } "[${ flagSummary } ]"`
0 commit comments