-
-
Notifications
You must be signed in to change notification settings - Fork 392
Add --begin flag to start/stop progress on tasks #105
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
Add --begin flag to start/stop progress on tasks #105
Conversation
|
Super cool was just looking at how to do this, really nice ✨ |
lib/help.js
Outdated
| --timeline, -i Display timeline view | ||
| --delete, -d Delete item | ||
| --check, -c Check/uncheck task | ||
| --begin, -b Start/stop task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of stop, we could maybe go with something a bit more fitting like pause, for example:
--begin, -b Start/pause task
lib/render.js
Outdated
| signale.config({displayLabel: false}); | ||
|
|
||
| const {error, log, note, pending, success} = signale; | ||
| const awaiting = signale.await; // Avoids "await outside async function" lint error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const {await: awaiting, error, log, note, pending, success} = signale;
lib/render.js
Outdated
| success({prefix, message, suffix}); | ||
| } | ||
|
|
||
| markStopped(ids) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markPaused(ids) {
lib/render.js
Outdated
| return; | ||
| } | ||
| const [prefix, suffix] = ['\n', grey(ids.join(', '))]; | ||
| const message = `Stopped ${ids.length > 1 ? 'tasks' : 'task'}:`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const message = `Paused ${ids.length > 1 ? 'tasks' : 'task'}:`;
lib/taskbook.js
Outdated
| beginTasks(ids) { | ||
| ids = this._validateIDs(ids); | ||
| const {_data} = this; | ||
| const [started, stopped] = [[], []]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [started, paused] = [[], []];| ids.forEach(id => { | ||
| _data[id].inProgress = !_data[id].inProgress; | ||
| return _data[id].inProgress ? started.push(id) : stopped.push(id); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also avoid the case where both the isComplete and inProgress attributes are set to true, something that can be done by setting the isComplete attribute of each iterated item to false, thus achieving mutual exclusion:
ids.forEach(id => {
_data[id].isComplete = false;
_data[id].inProgress = !_data[id].inProgress;
return _data[id].inProgress ? started.push(id) : paused.push(id);
});The same should be done for the checkTasks(ids) method, on line 342, where inProgress should be set to false.
lib/taskbook.js
Outdated
|
|
||
| this._save(_data); | ||
| render.markStarted(started); | ||
| render.markStopped(stopped); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render.markPaused(paused);
readme.md
Outdated
| --timeline, -i Display timeline view | ||
| --delete, -d Delete item | ||
| --check, -c Check/uncheck task | ||
| --begin, -b Start/stop task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--begin, -b Start/pause task
readme.md
Outdated
|
|
||
| ### Begin Task | ||
|
|
||
| To mark a task as started/stopped, use the `--begin`/`-b` option followed by the ids of the target tasks. The functionality of this option is the same as the one of the above described `--check` option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To mark a task as started/paused, ...
klaudiosinani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Just a couple of tweaks and it's good to go!
Also, please feel free to share your thoughts on the proposed changes : )
|
I agree with these changes, "stopping" a task could be interpreted as removing it whereas "pausing" has less implications of side effects. I'll apply these changes as soon as I'm able 👍 |
|
Got the changes applied and rebased with master, let me know if you see anything else that needs changing! |
|
Looks awesome! Thank you a lot for taking the time to contribute! |
This PR adds a
--beginflag to mark tasks as "in progress." This should resolve #92.I chose
--beginbecause-bis available as a shorthand and because I couldn't think of a verb like check/uncheck or star/unstar. Tasks in progress are rendered usingsignale.await, which displays a blue ellipsis (…). Let me know if a custom signal should be added, since notes also use blue and the ellipsis might not be intuitive.Here's what the usage looks like right now:

And here's the list command (with support for "progress", "started", and "begun"):
