Skip to content

Conversation

@codehearts
Copy link
Contributor

This PR adds a --begin flag to mark tasks as "in progress." This should resolve #92.

I chose --begin because -b is available as a shorthand and because I couldn't think of a verb like check/uncheck or star/unstar. Tasks in progress are rendered using signale.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:
screen shot 2018-10-14 at 21 26 44

And here's the list command (with support for "progress", "started", and "begun"):
screen shot 2018-10-14 at 21 27 45

@gabrielcsapo
Copy link

Super cool was just looking at how to do this, really nice ✨

@klaudiosinani klaudiosinani self-requested a review January 22, 2019 22:37
lib/help.js Outdated
--timeline, -i Display timeline view
--delete, -d Delete item
--check, -c Check/uncheck task
--begin, -b Start/stop task
Copy link
Owner

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
Copy link
Owner

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) {
Copy link
Owner

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'}:`;
Copy link
Owner

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] = [[], []];
Copy link
Owner

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);
});
Copy link
Owner

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);
Copy link
Owner

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
Copy link
Owner

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.
Copy link
Owner

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, ...

Copy link
Owner

@klaudiosinani klaudiosinani left a 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 : )

@klaudiosinani klaudiosinani added the enhancement New feature or request label Jan 23, 2019
@codehearts
Copy link
Contributor Author

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 👍

@codehearts
Copy link
Contributor Author

Got the changes applied and rebased with master, let me know if you see anything else that needs changing!

@klaudiosinani
Copy link
Owner

Looks awesome! Thank you a lot for taking the time to contribute!

@klaudiosinani klaudiosinani merged commit 904a007 into klaudiosinani:master Jan 27, 2019
@codehearts codehearts deleted the in-progress-status-for-tasks branch January 27, 2019 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request:Please add task in process status

3 participants