-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
43 lines (34 loc) · 1.02 KB
/
Copy pathcli.js
File metadata and controls
43 lines (34 loc) · 1.02 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
#!/usr/bin/env node
import { argv } from 'node:process'
import { parseArgs } from 'node:util'
import { externalSort } from './src/external-sort.js';
await main();
async function main() {
const options = {
output: {
type: 'string',
short: 'o'
},
input: {
type: 'string',
short: 'i'
},
memory: {
type: 'string',
short: 'm'
},
workingDir: {
type: 'string',
short: 'd',
raw: 'working-dir'
}
}
const { values, positionals } = parseArgs({ argv, options })
const inputPath = values.input
const outputPath = values.output
const memory = parseInt(values.memory)
const workingDir = values.workingDir
const compareFn = (a, b) => a.toString().localeCompare(b.toString());
// const compareFn = (a, b) => Number(a.toString()) - Number(b.toString());
await externalSort(inputPath, outputPath, workingDir, memory, false, compareFn);
}