aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
blob: f6d46d6587cb74a17562458c67fc647a47b5d658 (plain) (blame)
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
import { program } from 'commander'
import { createContext } from './context'
import { cleanup } from './eval'
import { evalList } from './util'

const main = () => {
  program
    .name('ts-types-lang')
    .description(
      `A runtime for typescript's type system that turns it into a general purpose, purely functional programming language!`
    )

  program
    .command('run')
    .description('Run a typescript .ts file')
    .argument('<file>', 'Typescript file to run')
    .action(async (filePath) => {
      const ctx = createContext({ filePath })
      const resultType = ctx.entryPoint.getType()
      const effects = resultType.isTuple()
        ? resultType.getTupleElements()
        : [resultType]
      await evalList(ctx, effects)
    })

  return program.parseAsync()
}

main().finally(() => cleanup())