diff --git a/src/commands/ls.ts b/src/commands/ls.ts index ebc5610..17b6ba6 100644 --- a/src/commands/ls.ts +++ b/src/commands/ls.ts @@ -1,15 +1,20 @@ -import { system, autoColorString } from '@kernel:base'; +import { system, autoColorString, reverseAliasMap } from '@kernel:base'; import chalk from 'chalk'; export default function ls(flags: any) { // if(flags) console.log(flags) console.log('Instances', chalk.ansi256(242)('(' + system.instances.size + ')')); - for(const [k, v] of system.instances) { - console.log( - ' ' - + autoColorString(k.substring(0, 4)) - + ':', JSON.stringify(v.config, null, 2).replace('\n', '\n ').trim() - ); + const aliases = reverseAliasMap(); + for(const [id, instance] of system.instances) { + if(aliases.has(id)) { + console.log(' ' + autoColorString(aliases.get(id)) + chalk.ansi256(242)(' (' + id + ')')); + } else { + console.log(' ' + autoColorString(id.substring(0, 8)) + chalk.ansi256(242)(' (' + instance.module + ')')); + } + + for(const [configKey, configVal] of Object.entries(instance.config)) { + console.log(' ' + chalk.ansi256(240)(configKey + ': ' + configVal)); + } } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 182988a..827e2ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,14 @@ export const system = { aliases: new Map() } +export function reverseAliasMap() { + const map = new Map(); + for(const [u, v] of system.aliases.entries()) { + map.set(v, u) + } + return map; +} + function checkpoint(string: string) { console.log(chalk.black.bgAnsi256(204)(' ' + string + ' ')); }