Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement configurable tag delimiter; default @ #155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"default": {
"taskbookDirectory": "~",
"displayCompleteTasks": true,
"displayProgressOverview": true
"displayProgressOverview": true,
"tagDelimiter": "@"
}
},
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ The following illustrates all the available options with their respective defaul
{
"taskbookDirectory": "~",
"displayCompleteTasks": true,
"displayProgressOverview": true
"displayProgressOverview": true,
"tagDelimiter": "@"
}
```

Expand Down Expand Up @@ -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.
Expand Down
25 changes: 15 additions & 10 deletions src/taskbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -19,6 +20,10 @@ class Taskbook {
return this._storage.get();
}

get _configuration() {
return config.get();
}

_arrayify(x) {
return Array.isArray(x) ? x : [x];
}
Expand Down Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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));
Expand All @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down