aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-09 19:38:28 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-09 19:38:28 +0530
commit2af211f1bd6a5c81ee7acd2ded2bfacf4dcfb2a4 (patch)
treeb1face34438aab4a702ace78c027b280e967f388 /src/index.ts
parent592f866637bfb8ef8a4a5c31e0984abf6df82532 (diff)
downloadts-types-lang-2af211f1bd6a5c81ee7acd2ded2bfacf4dcfb2a4.tar.gz
ts-types-lang-2af211f1bd6a5c81ee7acd2ded2bfacf4dcfb2a4.zip
feat: cli donezy
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/index.ts b/src/index.ts
index 65349fc..01420c8 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,15 +1,27 @@
+import { program } from 'commander'
import { createContext } from './context'
-import { evalList } from './eval'
+import { cleanup, evalList } from './eval'
-const main = async () => {
- const ctx = createContext()
- const resultType = ctx.entryPoint.getType()
- const effects = resultType.isTuple()
- ? resultType.getTupleElements()
- : [resultType]
- await evalList(ctx, effects)
+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()
- .then(() => process.exit(0))
- .catch((e) => (console.error(e), process.exit(1)))
+ .finally(() => cleanup())