Skip to content

Commit

Permalink
Show groups in gitte list output (#193)
Browse files Browse the repository at this point in the history
* Initial commit

* Changed action_obj to const

* Use map function

* Prettier optimized

---------

Co-authored-by: Dennis Staal <dest@cego.dk>
  • Loading branch information
staal0 and Dennis Staal authored Jan 22, 2024
1 parent d6bdb29 commit 8b5ea2b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/cmds/list.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { loadConfig } from "../../src/config_loader";
import chalk from "chalk";
import { errorHandler } from "../../src/error_handler";
import { ProjectAction } from "../../src/types/config";

// noinspection JSUnusedGlobalSymbols
export const command = "list";
// noinspection JSUnusedGlobalSymbols
export const describe = "List all projects and their actions";

function actionToPrettyString(actions: [string, ProjectAction]) {
return chalk`{cyan <${actions[0]}>} {magenta <${Object.keys(actions[1].groups)}>}`;
}

// noinspection JSUnusedGlobalSymbols
export async function handler(argv: any) {
try {
const config = await loadConfig(argv.cwd as string, argv.needs, false);
// const action_obj: Record<string, Record<string, string[]>> = {};

for (const [name, project] of Object.entries(config.projects)) {
console.log(chalk`{bold ${name}:} {cyan [${Object.keys(project.actions).join(", ")}]}`);
console.log(chalk`{bold ${name}:} ${Object.entries(project.actions).map(actionToPrettyString)}`);
}
} catch (e) {
errorHandler(e);
Expand Down

0 comments on commit 8b5ea2b

Please sign in to comment.