Skip to content

Commit 585176a

Browse files
committed
fix(list): print meta info to list command (#32)
This prints to stderr: - Account SID and redacted Auth Token - Service SID or name if available - Environment fix #32
1 parent 486ae73 commit 585176a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/printers/list.ts

+22-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import logSymbols from 'log-symbols';
1616
import title from 'title';
1717
import size from 'window-size';
1818
import { ListConfig } from '../config/list';
19-
import { shouldPrettyPrint } from './utils';
19+
import { redactPartOfString, shouldPrettyPrint } from './utils';
2020

2121
type KeyMaps = {
2222
[key in ListOptions]: string[];
@@ -102,7 +102,7 @@ const extendedKeys: KeyMaps = {
102102
};
103103

104104
function formatDate(dateStr: string) {
105-
return new Date(dateStr).toString();
105+
return new Date(dateStr).toString().slice(4, 33);
106106
}
107107

108108
function sortByAccess(resA: CommonType, resB: CommonType) {
@@ -283,7 +283,7 @@ function prettyPrintSection<T extends ListOptions>(
283283
content = prettyPrintFunctionsOrAssets(data);
284284
}
285285
const output = stripIndent`
286-
${sectionHeader}\n\n${content}\n\n${chalk.dim(LONG_LINE)}\n
286+
${sectionHeader}\n\n${content}\n\n\n
287287
`;
288288
return output;
289289
}
@@ -292,8 +292,26 @@ function printListResultTerminal(result: ListResult, config: ListConfig): void {
292292
const sections = Object.keys(result) as ListOptions[];
293293
const output = sections
294294
.map(section => prettyPrintSection(section, result[section]))
295-
.join('\n\n');
295+
.join(`\n\n${chalk.dim(LONG_LINE)}\n\n`);
296296

297+
let metaInfo = stripIndent(chalk`
298+
{cyan.bold Account} ${config.accountSid}
299+
{cyan.bold Token} ${redactPartOfString(config.authToken)}
300+
`);
301+
302+
if (config.serviceSid || config.serviceName) {
303+
metaInfo += chalk`\n{cyan.bold Service} ${config.serviceSid ||
304+
config.serviceName}`;
305+
}
306+
307+
if (config.environment) {
308+
metaInfo += chalk`\n{cyan.bold Environment} ${config.environment}`;
309+
}
310+
311+
if (config.environment) {
312+
}
313+
314+
process.stderr.write(metaInfo + '\n\n');
297315
console.log(output);
298316
}
299317

0 commit comments

Comments
 (0)