CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/project/jupyter/convert/util.ts
Views: 687
1
2
export function parseTo(args: string[]): { to: string; j: number } {
3
let j: number = 0;
4
let to: string = "";
5
for (let i = 0; i < args.length; i++) {
6
if (args[i] === "--to") {
7
j = i;
8
to = args[i + 1];
9
break;
10
}
11
}
12
return { to, j };
13
}
14
15
export function parseSource(args: string[]): string {
16
for (let i = 0; i < args.length; i++) {
17
if (args[i].startsWith("--")) {
18
if (args[i] != "--" && !args[i].includes("=")) {
19
// skip argument to --
20
i += 1;
21
}
22
continue;
23
}
24
// doesn't start with -- or wasn't next arg skipped due to starting with --
25
return args[i];
26
}
27
throw Error("no source");
28
}
29
30