From 7b4d29d16f3e3e75ab76b46d6788571f80dac315 Mon Sep 17 00:00:00 2001 From: Rafa Mel Date: Thu, 18 Feb 2021 10:36:05 +0100 Subject: [PATCH] feat(tasks): adds list command --- src/tasks/commands/index.ts | 1 + src/tasks/commands/list.ts | 18 ++++++++++++++++++ src/tasks/index.ts | 1 + 3 files changed, 20 insertions(+) create mode 100644 src/tasks/commands/index.ts create mode 100644 src/tasks/commands/list.ts diff --git a/src/tasks/commands/index.ts b/src/tasks/commands/index.ts new file mode 100644 index 0000000..7182513 --- /dev/null +++ b/src/tasks/commands/index.ts @@ -0,0 +1 @@ +export * from './list'; diff --git a/src/tasks/commands/list.ts b/src/tasks/commands/list.ts new file mode 100644 index 0000000..e37e6fb --- /dev/null +++ b/src/tasks/commands/list.ts @@ -0,0 +1,18 @@ +import { Task, Context } from '../../definitions'; +import { parseRecord } from '../../helpers/parse-record'; +import { print } from '../create/print'; +import { into } from 'pipettes'; +import chalk from 'chalk'; + +export function list(tasks: Task.Record): Task.Sync { + return (ctx: Context): void => { + const str = parseRecord(tasks) + .map((item) => { + return ' '.repeat((item.route.length - 1) * 2) + item.name; + }) + .map((str) => chalk.bold(str)) + .join('\n'); + + into(ctx, print(str)); + }; +} diff --git a/src/tasks/index.ts b/src/tasks/index.ts index fd50361..13a2ddb 100644 --- a/src/tasks/index.ts +++ b/src/tasks/index.ts @@ -1,3 +1,4 @@ +export * from './commands'; export * from './consume'; export * from './create'; export * from './transform';