From d85781b89b380bf8443d1d528843f87b3f8d7350 Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 17 Apr 2012 01:22:20 +0900 Subject: Add ":usi task show foo" --- usi.js | 145 +++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 88 insertions(+), 57 deletions(-) (limited to 'usi.js') diff --git a/usi.js b/usi.js index fe8db8f..9a703a0 100644 --- a/usi.js +++ b/usi.js @@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE. // INFO {{{ let INFO = <> - ; + for (let [, [d, [a, b]]] in Iterator(cs)) { + let hl = (n - d) > 0 ? 'ErrorMsg' : ''; + contents += {a}{b}; + } + liberator.echo(<>{contents}
); + } + } + ); + }), // }}} }; // }}} const CommandOptions = { // {{{ @@ -743,7 +796,36 @@ let INFO = names: 'p[ostpone]', description: 'Postpone a task', onComplete: TaskActionOnComplete('Task was postponed') - }) // }}} + }), // }}} + new Command( + ['s[how]'], + 'Show tasks', + function (args) { + Cow.showTasks(args.length && args); + }, + { + completer: function (context, args) { + context.incomplete = true; + + Cow.get( + { + method: 'rtm.lists.getList', + }, + { + synchronize: true, + cache: 'lists.getList', + onComplete: function (result) { + context.completions = [ + [v.@name, v.@id] + for ([k, v] in Iterator(result.lists.list)) + ]; + context.incomplete = false; + } + } + ); + } + } + ) ]; // }}} TransactionSubCommands = [ // {{{ @@ -790,60 +872,9 @@ let INFO = new Command( ['t[ask]'], 'Task control', - Combo(function (c, [args]) { - Cow.get( - { - method: 'rtm.lists.getList', - }, - { - cache: 'lists.getList', - onComplete: function (result) { - let table = {}; - for (let [k, v] in Iterator(result.lists.list)) - table[v.@id] = v.@name; - c.next(table); - } - } - ); - - let table = yield; - - Cow.get( - { - method: 'rtm.tasks.getList', - filter: 'status:incomplete' - }, - { - cache: 'rtm.tasks.getList?filter=status:incomplete', - onComplete: function (result) { - let cs = []; - let lists = args['-lists']; - - for (let [, list] in Iterator(result.tasks.list)) { - if (lists && lists.every(function (name) table[list.@id] != name)) - continue; - for (let [, taskseries] in Iterator(list.taskseries)) { - for (let [, task] in Iterator(taskseries.task)) { - cs.push([ - let (d = Utils.toDate(task.@due)) - (d ? d.getTime() : Infinity), - [taskseries.@name, Utils.toSmartDateText(task.@due)] - ]); - } - } - } - let n = new Date().getTime(); - Utils.timeArraySort(cs); - let contents = <>; - for (let [, [d, [a, b]]] in Iterator(cs)) { - let hl = (n - d) > 0 ? 'ErrorMsg' : ''; - contents += {a}{b}; - } - liberator.echo(<>{contents}
); - } - } - ); - }), + function (args) { + Cow.showTasks(args['-lists']); + }, { options: [CommandOptions.lists], subCommands: TaskSubCommands -- cgit v1.2.3