info command
This commit is contained in:
parent
0f5fd50fec
commit
830cd4e45d
|
|
@ -37,6 +37,34 @@ async function post<T, B = unknown>(url: string, body?: B): Promise<T | undefine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function infoApp(name: string) {
|
||||||
|
const app: App | undefined = await get(`/api/apps/${name}`)
|
||||||
|
if (!app) {
|
||||||
|
console.error(`App not found: ${name}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const icon = STATE_ICONS[app.state] ?? '◯'
|
||||||
|
console.log(`${icon} ${color.bold(app.name)}`)
|
||||||
|
console.log(` State: ${app.state}`)
|
||||||
|
if (app.port) {
|
||||||
|
console.log(` Port: ${app.port}`)
|
||||||
|
console.log(` URL: http://localhost:${app.port}`)
|
||||||
|
}
|
||||||
|
if (app.started) {
|
||||||
|
const uptime = Date.now() - app.started
|
||||||
|
const seconds = Math.floor(uptime / 1000) % 60
|
||||||
|
const minutes = Math.floor(uptime / 60000) % 60
|
||||||
|
const hours = Math.floor(uptime / 3600000)
|
||||||
|
const parts = []
|
||||||
|
if (hours) parts.push(`${hours}h`)
|
||||||
|
if (minutes) parts.push(`${minutes}m`)
|
||||||
|
parts.push(`${seconds}s`)
|
||||||
|
console.log(` Uptime: ${parts.join(' ')}`)
|
||||||
|
}
|
||||||
|
if (app.error) console.log(` Error: ${color.red(app.error)}`)
|
||||||
|
}
|
||||||
|
|
||||||
async function listApps() {
|
async function listApps() {
|
||||||
const apps: App[] | undefined = await get('/api/apps')
|
const apps: App[] | undefined = await get('/api/apps')
|
||||||
if (!apps) return
|
if (!apps) return
|
||||||
|
|
@ -130,6 +158,12 @@ program
|
||||||
.name('toes')
|
.name('toes')
|
||||||
.version('0.0.1', '-v, --version')
|
.version('0.0.1', '-v, --version')
|
||||||
|
|
||||||
|
program
|
||||||
|
.command('info')
|
||||||
|
.description('Show info for an app')
|
||||||
|
.argument('<name>', 'app name')
|
||||||
|
.action(infoApp)
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('list')
|
.command('list')
|
||||||
.description('List all apps')
|
.description('List all apps')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user