Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 6x 6x 6x 1x 1x 1x 5x 5x 5x 6x 1x 1x 1x 4x 4x 4x 4x 4x 6x 4x 6x 1x 1x 1x 3x 3x 3x 6x 2x 2x 1x 1x 1x 2x 2x 2x 2x 1x | const kanbn = require('../main');
const utility = require('../utility');
/**
* Restore a task from the archive
* @param {string} taskId
* @param {string|null} columnName
*/
function restoreTask(taskId, columnName) {
kanbn
.restoreTask(taskId, columnName)
.then(taskId => {
console.log(`Restored task "${taskId}" from the archive`);
})
.catch(error => {
utility.error(error);
});
}
module.exports = async args => {
// Make sure kanbn has been initialised
if (!await kanbn.initialised()) {
utility.error('Kanbn has not been initialised in this folder\nTry running: {b}kanbn init{b}');
return;
}
// Get the task that we're archiving
const taskId = args._[1];
if (!taskId) {
utility.error('No task id specified\nTry running {b}kanbn restore "task id"{b}');
return;
}
// Get the index and make sure it has some columns
let index;
try {
index = await kanbn.getIndex();
} catch (error) {
utility.error(error);
return;
}
const columnNames = Object.keys(index.columns);
if (!columnNames.length) {
utility.error('No columns defined in the index\nTry running {b}kanbn init -c "column name"{b}');
return;
}
// Get column name if specified
let columnName = null;
if (args.column) {
columnName = utility.strArg(args.column);
if (columnNames.indexOf(columnName) === -1) {
utility.error(`Column "${columnName}" doesn't exist`);
return;
}
}
// Archive task
restoreTask(taskId, columnName);
};
|