todolists
Version:
Todolist in NodeJs CLI
58 lines • 1.76 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const data_base_1 = require("./data_base");
const style_1 = require("./style");
const todo_status_1 = require("./enum/todo_status");
class Command {
constructor(todoList, cli) {
this.cli = cli;
this.todoList = todoList;
this.dataBase = new data_base_1.default();
this.arg = [].slice.call(arguments, 2);
}
listFiles(files) {
if (typeof files === 'object') {
const style = new style_1.default(files);
style.default();
}
}
add(content) {
this.todoList.create(content);
this.listPending();
this.dataBase.writeData(this.todoList.toStringify());
}
remove(id) {
this.todoList.clearById(id);
this.listPending();
this.dataBase.writeData(this.todoList.toStringify());
}
listPending() {
const file = this.todoList.getItemListByStatus(todo_status_1.todoStatusEnum.PENDING);
this.listFiles(file);
}
listAll() {
const file = this.todoList.getList;
this.listFiles(file);
}
check(id) {
this.todoList.check(id);
this.listPending();
this.dataBase.writeData(this.todoList.toStringify());
}
uncheck(id) {
this.todoList.uncheck(id);
this.listPending();
this.dataBase.writeData(this.todoList.toStringify());
}
removeAll() {
this.todoList.clearAll();
this.dataBase.writeData(this.todoList.toStringify());
}
resort() {
this.todoList.resort();
this.dataBase.writeData(this.todoList.toStringify());
this.listAll();
}
}
exports.default = Command;
//# sourceMappingURL=cli_command.js.map