'use strict';

const fmt = require('../fmt');
const rgx = /@desc(.*)/;

/**
 * List available tasks within a Fly instance
 * @param {Object}  tasks  The available tasks
 * @param {Boolean} bare   Should output be unstyled?
 */
module.exports = function (tasks, bare) {
	bare = bare || false;
	tasks = tasks || {};

	if (!bare) {
		console.log('\n' + fmt.dim.bold('Available tasks'))
	}

	// parse tasks' descriptions, if any
	for (let k in tasks) {
		const arr = rgx.exec(tasks[k].toString());
		const txt = arr ? arr.pop().replace(/\*\//, '') : '';
		console.log((bare ? '%s' : ' ') + fmt.title + '\t' + txt, task);
	}

	if (!bare) {
		console.log();
	}
};

@@ -351,16 +351,16 @@
 fmt.
-dim.bold
+text.dim
 ('Av
@@ -375,16 +375,17 @@
 tasks'))
+;
 %0A%09%7D%0A%0A%09//
@@ -542,24 +542,71 @@
 '') : '';%0A%09%09
+console.log(%60%5Ct$%7Bfmt.title(k)%7D%5Ct$%7Btxt%7D%60);%0A%09%09// 
 console.log(
@@ -651,19 +651,16 @@
  + txt, 
-tas
 k);%0A%09%7D%0A%0A

fix cli.list; full function string was printed