From 7a3fb108cbf1ee64fd89a39c6121a2fa46ae1b73 Mon Sep 17 00:00:00 2001 From: Brandon Smith Date: Sun, 15 Sep 2019 10:48:10 -0400 Subject: [PATCH 1/2] Implement configurable tag delimiter --- package.json | 3 ++- readme.md | 12 +++++++++++- src/taskbook.js | 25 +++++++++++++++---------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a18c8691..35a75376 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "default": { "taskbookDirectory": "~", "displayCompleteTasks": true, - "displayProgressOverview": true + "displayProgressOverview": true, + "tagDelimiter": "@" } }, "scripts": { diff --git a/readme.md b/readme.md index b06faeb4..39a1fc35 100644 --- a/readme.md +++ b/readme.md @@ -160,7 +160,8 @@ The following illustrates all the available options with their respective defaul { "taskbookDirectory": "~", "displayCompleteTasks": true, - "displayProgressOverview": true + "displayProgressOverview": true, + "tagDelimiter": "@" } ``` @@ -189,6 +190,15 @@ Display tasks that are marked as complete. Display progress overview below the timeline and board views. +##### `tagDelimiter` + +- Type: `String` +- Default: `@` + +Specify the delimiter used in tag commands such as `@board` and `@id`. + +Note: PowerShell users will need to override this with another character. + ## Flight Manual The following is a minor walkthrough containing a set of examples on how to use taskbook. diff --git a/src/taskbook.js b/src/taskbook.js index d6ff4cf1..3d7af53b 100644 --- a/src/taskbook.js +++ b/src/taskbook.js @@ -5,6 +5,7 @@ const Task = require('./task'); const Note = require('./note'); const Storage = require('./storage'); const render = require('./render'); +const config = require('./config') class Taskbook { constructor() { @@ -19,6 +20,10 @@ class Taskbook { return this._storage.get(); } + get _configuration() { + return config.get(); + } + _arrayify(x) { return Array.isArray(x) ? x : [x]; } @@ -108,7 +113,7 @@ class Taskbook { input.forEach(x => { if (!this._isPriorityOpt(x)) { - return x.startsWith('@') && x.length > 1 ? boards.push(x) : desc.push(x); + return x.startsWith(this._configuration.tagDelimiter) && x.length > 1 ? boards.push(x) : desc.push(x); } }); @@ -407,7 +412,7 @@ class Taskbook { } editDescription(input) { - const targets = input.filter(x => x.startsWith('@')); + const targets = input.filter(x => x.startsWith(this._configuration.tagDelimiter)); if (targets.length === 0) { render.missingID(); @@ -420,7 +425,7 @@ class Taskbook { } const [target] = targets; - const id = this._validateIDs(target.replace('@', '')); + const id = this._validateIDs(target.replace(this._configuration.tagDelimiter, '')); const newDesc = input.filter(x => x !== target).join(' '); if (newDesc.length === 0) { @@ -454,11 +459,11 @@ class Taskbook { const storedBoards = this._getBoards(); terms.forEach(x => { - if (storedBoards.indexOf(`@${x}`) === -1) { + if (storedBoards.indexOf(`${this._configuration.tagDelimiter}${x}`) === -1) { return x === 'myboard' ? boards.push('My Board') : attributes.push(x); } - return boards.push(`@${x}`); + return boards.push(`${this._configuration.tagDelimiter}${x}`); }); [boards, attributes] = [boards, attributes].map(x => this._removeDuplicates(x)); @@ -469,7 +474,7 @@ class Taskbook { moveBoards(input) { let boards = []; - const targets = input.filter(x => x.startsWith('@')); + const targets = input.filter(x => x.startsWith(this._configuration.tagDelimiter)); if (targets.length === 0) { render.missingID(); @@ -482,10 +487,10 @@ class Taskbook { } const [target] = targets; - const id = this._validateIDs(target.replace('@', '')); + const id = this._validateIDs(target.replace(this._configuration.tagDelimiter, '')); input.filter(x => x !== target).forEach(x => { - boards.push(x === 'myboard' ? 'My Board' : `@${x}`); + boards.push(x === 'myboard' ? 'My Board' : `${this._configuration.tagDelimiter}${x}`); }); if (boards.length === 0) { @@ -537,7 +542,7 @@ class Taskbook { process.exit(1); } - const targets = input.filter(x => x.startsWith('@')); + const targets = input.filter(x => x.startsWith(this._configuration.tagDelimiter)); if (targets.length === 0) { render.missingID(); @@ -550,7 +555,7 @@ class Taskbook { } const [target] = targets; - const id = this._validateIDs(target.replace('@', '')); + const id = this._validateIDs(target.replace(this._configuration.tagDelimiter, '')); const {_data} = this; _data[id].priority = level; From ba1d75d7c8ca19bc65ac518cbbe660313c40c943 Mon Sep 17 00:00:00 2001 From: Brandon Smith Date: Sun, 15 Sep 2019 10:57:29 -0400 Subject: [PATCH 2/2] lint: add missing semicolon --- src/taskbook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/taskbook.js b/src/taskbook.js index 3d7af53b..f772112e 100644 --- a/src/taskbook.js +++ b/src/taskbook.js @@ -5,7 +5,7 @@ const Task = require('./task'); const Note = require('./note'); const Storage = require('./storage'); const render = require('./render'); -const config = require('./config') +const config = require('./config'); class Taskbook { constructor() {