@@ -2,10 +2,20 @@ import { underline, bold } from 'picocolors';
22import { readFile } from 'hexo-fs' ;
33import { join } from 'path' ;
44import Promise from 'bluebird' ;
5+ import type Context from '../context' ;
6+ import type { Callback , Store , Command } from '../types' ;
57
68const COMPLETION_DIR = join ( __dirname , '../../completion' ) ;
79
8- function helpConsole ( args ) {
10+ interface HelpArgs {
11+ _ : string [ ] ;
12+ v ?: boolean ;
13+ version ?: boolean ;
14+ consoleList ?: boolean ;
15+ completion ?: string ;
16+ }
17+
18+ function helpConsole ( this : Context , args : HelpArgs ) {
919 if ( args . v || args . version ) {
1020 return this . call ( 'version' ) ;
1121 } else if ( args . consoleList ) {
@@ -24,7 +34,7 @@ function helpConsole(args) {
2434 return printAllHelp ( this . extend . console . list ( ) ) ;
2535}
2636
27- function printHelpForCommand ( command , data ) {
37+ function printHelpForCommand ( command : string , data : Callback ) {
2838 const { options } = data ;
2939
3040 const desc = options . description || options . desc || data . description || data . desc ;
@@ -40,7 +50,7 @@ function printHelpForCommand(command, data) {
4050 return Promise . resolve ( ) ;
4151}
4252
43- function printAllHelp ( list ) {
53+ function printAllHelp ( list : Store ) {
4454 const keys = Object . keys ( list ) ;
4555 const commands = [ ] ;
4656 const { length } = keys ;
@@ -73,7 +83,7 @@ function printAllHelp(list) {
7383 return Promise . resolve ( ) ;
7484}
7585
76- function printList ( title , list ) {
86+ function printList ( title : string , list : Command [ ] ) {
7787 list . sort ( ( a , b ) => {
7888 const nameA = a . name ;
7989 const nameB = b . name ;
@@ -101,13 +111,13 @@ function printList(title, list) {
101111 return Promise . resolve ( ) ;
102112}
103113
104- function printConsoleList ( list ) {
114+ function printConsoleList ( list : Store ) {
105115 console . log ( Object . keys ( list ) . join ( '\n' ) ) ;
106116
107117 return Promise . resolve ( ) ;
108118}
109119
110- function printCompletion ( type ) {
120+ function printCompletion ( type : string ) {
111121 return readFile ( join ( COMPLETION_DIR , type ) ) . then ( content => {
112122 console . log ( content ) ;
113123 } ) ;
0 commit comments