-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
78 lines (63 loc) · 1.88 KB
/
main.ts
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import ts = require("typescript");
import fs = require("fs");
import { Project } from "./Project";
import { Reader } from "./Reader/Reader";
import { Writer } from "./Writer/Writer";
const program = require('commander');
if (process.argv.length < 3) {
console.error("Wrong command")
}
else {
switch (process.argv[2]) {
case "list-models": {
Reader.listModels(process.argv[3])
break
}
case "list-requests": {
Reader.listRequests(process.argv[3])
break
}
case "delete-request": {
Writer.deleteClass(process.argv[4],process.argv[3])
break
}
case "delete-model": {
Writer.deleteClass(process.argv[4],process.argv[3])
break
}
case "insert-model": {
const model = JSON.parse(process.argv[4])
Writer.insertModel(Project.normalizeModelType(model),process.argv[3])
break
}
case "update-model": {
const model = JSON.parse(process.argv[4])
Writer.updateModel(Project.normalizeModelType(model),process.argv[3])
break
}
case "insert-request": {
const request = JSON.parse(process.argv[4])
Writer.insertRequest(Project.normalizeRequestType(request),process.argv[3])
break
}
case "update-request": {
const request = JSON.parse(process.argv[4])
Writer.updateRequest(Project.normalizeRequestType(request),process.argv[3])
break
}
}
}
// function parse<ResponseType,ErrorType>(text: string, callback:(result:ResponseType)=>void, onError:(error:ErrorType)=>void) {
// try {
// callback(JSON.parse(text));
// }
// catch (e) {
// console.debug("error")
// onError(JSON.parse(text))
// }
// };
// parse<Project.Model,Project.Request>('{"name":"ololo","vars":[]}',(model)=>{
// const m = model as Project.Model
// console.debug(typeof(m))
// console.debug(model)
// },(request)=>{console.debug(request)})