Skip to content

Commit d250003

Browse files
committed
feat(cli): Adding json option to list accounts
1 parent 9387d95 commit d250003

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

templates/cli/lib/commands/generic.js.twig

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,24 @@ const login = new Command("login")
143143
login
144144
.command('list')
145145
.description("List available logged accounts.")
146-
.action(actionRunner(async () => {
146+
.option("-j, --json", "Output in JSON format")
147+
.action(actionRunner(async ({ json }) => {
147148
const logins = globalConfig.getLogins();
148149
const current = globalConfig.getCurrentLogin();
149150

150151
const data = [...logins.map((login => {
151152
return {
152153
'Current': login.id === current ? '*' : '',
153154
'ID': login.id,
154-
'Endpoint': login.endpoint,
155-
'Email': login.email
155+
'Email': login.email,
156+
'Endpoint': login.endpoint
156157
};
157158
}))];
158159

160+
if (json) {
161+
console.log(data);
162+
return;
163+
}
159164
drawTable(data);
160165

161166
}));

0 commit comments

Comments
 (0)