UNPKG

orgdo

Version:

Command-line tool to manage the Todo lists

87 lines (86 loc) 2.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Cli_1 = require("../../Cli"); const Client_1 = require("../../Client"); const utits_1 = require("../../utits"); const render = require("../../task-render"); exports.command = ["list", "ls"]; exports.describe = "List tasks"; function builder(cmd) { return cmd .option("all", { describe: "List all the tasks", type: "boolean" }) .option("tags", { describe: "Filter based on tags", type: "string" }) .option("priority", { describe: "Filter based on priority", choices: ["high", "medium", "low"] }) .option("status", { describe: "Filter based on status", choices: ["todo", "doing", "done", "canceled"] }) .option("name", { describe: "Filter based on name regexp", type: "string" }) .option("start", { describe: "Filter base on start time of task", type: "string" }) .option("started", { describe: "Filter base on started time of task", type: "string" }) .option("complete", { describe: "Filter base on complete time of task", type: "string" }) .option("completed", { describe: "Filter base on completed time of task", type: "string" }) .option("with-stat", { describe: "Show static of tasks", type: "boolean" }) .option("only-stat", { describe: "Show static of tasks only, hidden tasks list", type: "boolean" }); } exports.builder = builder; function handler(options) { utits_1.strToArr(options, "tags"); Client_1.default.init().then(client => { if (Object.keys(options).length === 2) { options = { status: ["todo", "doing"], start: "1", complete: "1" }; } new Cli_1.default(client) .list(options) .then(tasks => { if (tasks.length === 0) { Client_1.print("No tasks."); return; } let ret = ""; if (!options["only-stat"]) { ret += render.renderTasks(tasks); } if (options["with-stat"] || options["only-stat"]) { ret += render.renderTasksStatistic(tasks); } Client_1.print(ret); }) .catch(err => Client_1.printErrorAndExit(err)); }); } exports.handler = handler;