-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsid.ts
49 lines (40 loc) · 1.05 KB
/
lsid.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
import {Command, flags} from '@oclif/command'
import * as fs from "fs";
import { readTasks } from "../utils/task";
import { readConfig } from "../utils/config";
import { Task } from "todo.json";
import * as _ from "lodash";
export default class ListProj extends Command {
static description = 'List IDs'
static examples = [
`$ td lsid`,
`$ td lsid -D`
]
static flags = {
help: flags.help({char: 'h'}),
done: flags.boolean({
char: "D",
description: "list IDs of only done tasks"
})
}
async run() {
const { flags } = this.parse(ListProj);
const { todoPath, donePath } = readConfig();
let size = 0;
if (!flags.done) {
let todoTasks = [] as Task[];
if (fs.existsSync(todoPath)) {
todoTasks = readTasks(todoPath);
}
size = todoTasks.length;
}
if (flags.done) {
let doneTasks = [] as Task[];
if (fs.existsSync(donePath)) {
doneTasks = readTasks(donePath);
}
size = doneTasks.length;
}
this.log(_.range(1, size + 1).join("\n"));
}
}