-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathShellCommand.imba
More file actions
46 lines (32 loc) · 1.07 KB
/
ShellCommand.imba
File metadata and controls
46 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Prop } from '@formidablejs/console'
import { Command } from '../Command'
import { homedir } from 'os'
import { ImbaRepl } from 'imba-shell'
import { join } from 'path'
import { existsSync } from 'fs-extra'
import type { REPLServer } from 'repl'
export class ShellCommand < Command
get language
const appPackage = join(process.cwd!, 'package.json')
if !existsSync(appPackage)
return 'imba'
const value = require(appPackage).language || 'imba'
value.toLowerCase!
get signature
'shell {?--language}'
get description
'Interact with your application'
get props
{
language: Prop.options('Language to use inside the shell').options(['imba', 'typescript']).default(language)
}
get history
join homedir!, '.formidable_shell_history'
def handle
const imbaRepl = new ImbaRepl option('language'), '>>> ', history
imbaRepl.registerCallback do(ctx)
const context = app.context.registered
for key in Object.keys(context)
if !ctx[key] then ctx[key] = context[key]
const server\REPLServer = await imbaRepl.run!
server.on 'exit', do self.exit!