Skip to content

Commit 27d1bcb

Browse files
committed
feat: add typescript support
1 parent 147f290 commit 27d1bcb

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,45 @@
1+
import { Prop } from '@formidablejs/console'
12
import { Command } from '../Command'
23
import { homedir } from 'os'
34
import { ImbaRepl } from 'imba-shell'
45
import { join } from 'path'
6+
import { existsSync } from 'fs-extra'
57
import type { REPLServer } from 'repl'
68

79
export class ShellCommand < Command
810

11+
get language
12+
const appPackage = join(process.cwd!, 'package.json')
13+
14+
if !existsSync(appPackage)
15+
return 'imba'
16+
17+
const value = require(appPackage).language || 'imba'
18+
19+
value.toLowerCase!
20+
921
get signature
10-
'shell'
22+
'shell {?--language}'
1123

1224
get description
1325
'Interact with your application'
1426

27+
get props
28+
{
29+
language: Prop.options('Language to use inside the shell').options(['imba', 'typescript']).default(language)
30+
}
31+
1532
get history
1633
join homedir!, '.formidable_shell_history'
1734

1835
def handle
19-
const repl = new ImbaRepl '>>> ', history
36+
const imbaRepl = new ImbaRepl option('language'), '>>> ', history
2037

21-
repl.registerCallback do(ctx)
38+
imbaRepl.registerCallback do(ctx)
2239
const context = app.context.registered
2340

2441
Object.keys(context).forEach do(key) if !ctx[key] then ctx[key] = context[key]
2542

26-
const server\REPLServer = await repl.run!
43+
const server\REPLServer = await imbaRepl.run!
2744

2845
server.on 'exit', do self.exit!

0 commit comments

Comments
 (0)