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 tools = allApps.filter((app) => app.tool)
|
||||
|
||||
if (apps.length > 0) {
|
||||
console.log('apps:')
|
||||
if (tools.length === 0) {
|
||||
// No tools, just list apps without header/indent
|
||||
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:')
|
||||
for (const tool of tools) {
|
||||
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 port = app.port ? `\x1b[90m:${app.port}\x1b[0m` : ''
|
||||
const prefix = indent ? ' ' : ''
|
||||
|
||||
if (_showEmoji) {
|
||||
const icon = app.icon ?? '📦'
|
||||
return ` ${icon} ${app.name} ${status}${port}`
|
||||
return `${prefix}${icon} ${app.name} ${status}${port}`
|
||||
} 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 tools = _apps.filter(a => a.tool)
|
||||
|
||||
if (regularApps.length > 0) {
|
||||
lines.push('\x1b[1mApps\x1b[0m')
|
||||
if (tools.length === 0) {
|
||||
// No tools, just list apps without header/indent
|
||||
for (const app of regularApps) {
|
||||
lines.push(formatAppLine(app))
|
||||
lines.push(formatAppLine(app, false))
|
||||
}
|
||||
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')
|
||||
for (const app of tools) {
|
||||
lines.push(formatAppLine(app))
|
||||
lines.push(formatAppLine(app, true))
|
||||
}
|
||||
lines.push('')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user