11import { readFile , mkdir as mkDir , writeFile , rmdir as rmDir } from "fs/promises"
22import { resolve as resolvePath } from "path"
33import { homedir as homeDir } from "os"
4- import { pull , push , syncMacros , test , watch } from ".."
4+ import { generateTypings , pull , push , syncMacros , test , watch } from ".."
55import { redBright , yellowBright , greenBright , blueBright , cyanBright , magentaBright , bold , dim } from "ansi-colors"
66
77// let o = ""
@@ -124,6 +124,7 @@ for (let arg of process.argv.slice(2)) {
124124 const scripts = options . get ( "scripts" ) ?. toString ( ) . split ( "," ) || [ ]
125125 const colours = [ redBright , greenBright , yellowBright , blueBright , magentaBright , cyanBright ]
126126 const configUsers = config . users = config . users || { }
127+ const genTypes = options . get ( "gen-types" ) ?. toString ( )
127128
128129 watch (
129130 srcPath ,
@@ -142,7 +143,8 @@ for (let arg of process.argv.slice(2)) {
142143 ( configUsers [ user ] = configUsers [ user ] || { colour : colours [ Math . floor ( Math . random ( ) * colours . length ) ] ( user ) } ) . colour
143144 ) . join ( ", " )
144145 } [${ minLength } chars]`
145- )
146+ ) ,
147+ { genTypes }
146148 )
147149 } else
148150 console . log ( "you need to set hackmudPath in config before you can use this command" )
@@ -205,6 +207,20 @@ for (let arg of process.argv.slice(2)) {
205207 break
206208 }
207209
210+ case "gen-types" : {
211+ const srcPath = resolvePath ( commands [ 1 ] || "." )
212+ let targetPath : string
213+
214+ if ( commands [ 2 ] )
215+ targetPath = resolvePath ( commands [ 2 ] )
216+ else
217+ targetPath = resolvePath ( srcPath , "../player.d.ts" )
218+
219+ generateTypings ( srcPath , targetPath , ( await getConfig ( ) ) . hackmudPath )
220+
221+ break
222+ }
223+
208224 case "config" :
209225 switch ( commands [ 1 ] ) {
210226 case "get" :
0 commit comments