better LSing
parent
c23d25f5db
commit
4a74b36961
|
|
@ -1,15 +1,20 @@
|
||||||
import { system, autoColorString } from '@kernel:base';
|
import { system, autoColorString, reverseAliasMap } from '@kernel:base';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
export default function ls(flags: any) {
|
export default function ls(flags: any) {
|
||||||
// if(flags) console.log(flags)
|
// if(flags) console.log(flags)
|
||||||
|
|
||||||
console.log('Instances', chalk.ansi256(242)('(' + system.instances.size + ')'));
|
console.log('Instances', chalk.ansi256(242)('(' + system.instances.size + ')'));
|
||||||
for(const [k, v] of system.instances) {
|
const aliases = reverseAliasMap();
|
||||||
console.log(
|
for(const [id, instance] of system.instances) {
|
||||||
' '
|
if(aliases.has(id)) {
|
||||||
+ autoColorString(k.substring(0, 4))
|
console.log(' ' + autoColorString(aliases.get(id)) + chalk.ansi256(242)(' (' + id + ')'));
|
||||||
+ ':', JSON.stringify(v.config, null, 2).replace('\n', '\n ').trim()
|
} 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +28,14 @@ export const system = {
|
||||||
aliases: new Map<string, string>()
|
aliases: new Map<string, string>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function reverseAliasMap() {
|
||||||
|
const map = new Map<string, string>();
|
||||||
|
for(const [u, v] of system.aliases.entries()) {
|
||||||
|
map.set(v, u)
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
function checkpoint(string: string) {
|
function checkpoint(string: string) {
|
||||||
console.log(chalk.black.bgAnsi256(204)(' ' + string + ' '));
|
console.log(chalk.black.bgAnsi256(204)(' ' + string + ' '));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue