@@ -4,7 +4,7 @@ import stripAnsi = require('strip-ansi')
44import { castArray , compact , sortBy } from '../util'
55import * as Interfaces from '../interfaces'
66import { Example } from '../interfaces/command'
7- import { HelpFormatter } from './formatter'
7+ import { HelpFormatter , HelpSection , HelpSectionRenderer } from './formatter'
88import { DocOpts } from './docopts'
99
1010// Don't use os.EOL because we need to ensure that a string
2222if ( process . env . ConEmuANSI === 'ON' ) {
2323 dim = Chalk . gray
2424}
25-
26- export type HelpSection = { header : string ; body : string | [ string , string | undefined ] [ ] | undefined } | undefined ;
27- export type HelpSectionRenderer = ( data : { cmd : Interfaces . Command ; flags : Interfaces . Command . Flag [ ] ; args : Interfaces . Command . Arg [ ] } , header : string ) => HelpSection [ ] | string | undefined ;
28-
2925export class CommandHelp extends HelpFormatter {
3026 constructor (
3127 public command : Interfaces . Command ,
@@ -57,7 +53,7 @@ export class CommandHelp extends HelpFormatter {
5753
5854 protected groupFlags ( flags : Interfaces . Command . Flag [ ] ) {
5955 const mainFlags : Interfaces . Command . Flag [ ] = [ ]
60- const flagGroups : { [ index : string ] : Interfaces . Command . Flag [ ] } = { }
56+ const flagGroups : { [ index : string ] : Interfaces . Command . Flag [ ] } = { }
6157
6258 for ( const flag of flags ) {
6359 const group = flag . helpGroup
@@ -72,7 +68,7 @@ export class CommandHelp extends HelpFormatter {
7268 return { mainFlags, flagGroups}
7369 }
7470
75- protected sections ( ) : Array < { header : string ; generate : HelpSectionRenderer } > {
71+ protected sections ( ) : Array < { header : string ; generate : HelpSectionRenderer } > {
7672 return [
7773 {
7874 header : this . opts . usageHeader || 'USAGE' ,
@@ -131,7 +127,7 @@ export class CommandHelp extends HelpFormatter {
131127 if ( line . length > allowedSpacing ) {
132128 const splitIndex = line . substring ( 0 , allowedSpacing ) . lastIndexOf ( ' ' )
133129 return line . substring ( 0 , splitIndex ) + '\n' +
134- this . indent ( this . wrap ( line . substring ( splitIndex ) , this . indentSpacing * 2 ) )
130+ this . indent ( this . wrap ( line . substring ( splitIndex ) , this . indentSpacing * 2 ) )
135131 }
136132 return this . wrap ( line )
137133 } )
0 commit comments