minor
This commit is contained in:
parent
e4310bda6d
commit
b8434ef2df
|
|
@ -86,14 +86,19 @@ export async function listApps(options: ListAppsOptions) {
|
||||||
const apps = allApps.filter((app) => !app.tool)
|
const apps = allApps.filter((app) => !app.tool)
|
||||||
const tools = allApps.filter((app) => app.tool)
|
const tools = allApps.filter((app) => app.tool)
|
||||||
|
|
||||||
if (apps.length > 0) {
|
if (tools.length === 0) {
|
||||||
console.log('apps:')
|
// No tools, just list apps without header/indent
|
||||||
for (const app of apps) {
|
for (const app of apps) {
|
||||||
console.log(` ${STATE_ICONS[app.state] ?? '◯'} ${app.name}`)
|
console.log(`${STATE_ICONS[app.state] ?? '◯'} ${app.name}`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (apps.length > 0) {
|
||||||
|
console.log('apps:')
|
||||||
|
for (const app of apps) {
|
||||||
|
console.log(` ${STATE_ICONS[app.state] ?? '◯'} ${app.name}`)
|
||||||
|
}
|
||||||
|
console.log()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (tools.length > 0) {
|
|
||||||
if (apps.length > 0) console.log()
|
|
||||||
console.log('tools:')
|
console.log('tools:')
|
||||||
for (const tool of tools) {
|
for (const tool of tools) {
|
||||||
console.log(` ${STATE_ICONS[tool.state] ?? '◯'} ${tool.name}`)
|
console.log(` ${STATE_ICONS[tool.state] ?? '◯'} ${tool.name}`)
|
||||||
|
|
|
||||||
|
|
@ -47,15 +47,16 @@ const formatStatus = (app: App): string => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatAppLine = (app: App): string => {
|
const formatAppLine = (app: App, indent: boolean): string => {
|
||||||
const status = formatStatus(app)
|
const status = formatStatus(app)
|
||||||
const port = app.port ? `\x1b[90m:${app.port}\x1b[0m` : ''
|
const port = app.port ? `\x1b[90m:${app.port}\x1b[0m` : ''
|
||||||
|
const prefix = indent ? ' ' : ''
|
||||||
|
|
||||||
if (_showEmoji) {
|
if (_showEmoji) {
|
||||||
const icon = app.icon ?? '📦'
|
const icon = app.icon ?? '📦'
|
||||||
return ` ${icon} ${app.name} ${status}${port}`
|
return `${prefix}${icon} ${app.name} ${status}${port}`
|
||||||
} else {
|
} else {
|
||||||
return ` ${status} ${app.name}${port}`
|
return `${prefix}${status} ${app.name}${port}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,18 +87,24 @@ function render() {
|
||||||
const regularApps = _apps.filter(a => !a.tool)
|
const regularApps = _apps.filter(a => !a.tool)
|
||||||
const tools = _apps.filter(a => a.tool)
|
const tools = _apps.filter(a => a.tool)
|
||||||
|
|
||||||
if (regularApps.length > 0) {
|
if (tools.length === 0) {
|
||||||
lines.push('\x1b[1mApps\x1b[0m')
|
// No tools, just list apps without header/indent
|
||||||
for (const app of regularApps) {
|
for (const app of regularApps) {
|
||||||
lines.push(formatAppLine(app))
|
lines.push(formatAppLine(app, false))
|
||||||
}
|
}
|
||||||
lines.push('')
|
lines.push('')
|
||||||
}
|
} else {
|
||||||
|
if (regularApps.length > 0) {
|
||||||
|
lines.push('\x1b[1mApps\x1b[0m')
|
||||||
|
for (const app of regularApps) {
|
||||||
|
lines.push(formatAppLine(app, true))
|
||||||
|
}
|
||||||
|
lines.push('')
|
||||||
|
}
|
||||||
|
|
||||||
if (tools.length > 0) {
|
|
||||||
lines.push('\x1b[1mTools\x1b[0m')
|
lines.push('\x1b[1mTools\x1b[0m')
|
||||||
for (const app of tools) {
|
for (const app of tools) {
|
||||||
lines.push(formatAppLine(app))
|
lines.push(formatAppLine(app, true))
|
||||||
}
|
}
|
||||||
lines.push('')
|
lines.push('')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user