@kadena/kadena-cli
Version:
Kadena CLI tool to interact with the Kadena blockchain (manage keys, transactions, etc.)
50 lines • 1.71 kB
JavaScript
import { log } from './logger.js';
export const formatLength = 80;
export const displaySeparator = () => {
log.info(log.color.green('-'.repeat(formatLength)));
};
export const formatConfig = (key, value) => {
let valueDisplay;
if (value === undefined) {
valueDisplay = log.color.red('Not Set');
}
else if (key.toLowerCase().includes('password')) {
if (value === '') {
valueDisplay = 'no password set';
}
else {
valueDisplay = log.color.red('******');
}
}
else {
valueDisplay = log.color.green(value.toString());
}
const keyValue = `${key} : ${valueDisplay}`;
const remainingWidth = formatLength - keyValue.length > 0 ? formatLength - keyValue.length : 0;
return ` ${keyValue}${' '.repeat(remainingWidth)} `;
};
export const displayConfig = (config, indentation = '') => {
displaySeparator(); // Add horizontal line at the top
Object.getOwnPropertyNames(config).forEach((key) => {
const value = config[key];
let isObject = false;
let displayValue = value;
if (Array.isArray(value)) {
displayValue = JSON.stringify(value);
}
else if (value === null) {
displayValue = 'null';
}
else if (typeof value === 'object') {
isObject = true;
displayValue = '';
}
log.info(formatConfig(indentation + key, displayValue));
if (isObject) {
displayConfig(value, `${indentation} `);
}
});
if (indentation.length === 0)
displaySeparator(); // Add horizontal line at the bottom
};
//# sourceMappingURL=createCommandDisplayHelper.js.map