@@ -39,7 +39,7 @@ function enterAltBufferMode() {
39
39
console . log ( "\x1b[?1049h" )
40
40
}
41
41
42
- export function usage ( cmd = "dashboard" ) {
42
+ export function usage ( cmd : string ) {
43
43
return `Usage: codeflare ${ cmd } ${ validKinds ( ) . join ( "|" ) } [<jobId>|-N]`
44
44
}
45
45
@@ -67,7 +67,7 @@ async function lastNJob(profile: string, N: number) {
67
67
}
68
68
}
69
69
70
- export async function jobIdFrom ( args : Arguments < Options > , cmd = "dashboard" , offset = 2 ) {
70
+ export async function jobIdFrom ( args : Arguments < Options > , cmd : string , offset = 2 ) {
71
71
const profile = args . parsedOptions . p || ( await import ( "madwizard" ) . then ( ( _ ) => _ . Profiles . lastUsed ( ) ) )
72
72
73
73
const jobIdFromCommandLine = args . argvNoOptions [ args . argvNoOptions . indexOf ( cmd ) + offset ]
@@ -80,19 +80,19 @@ export async function jobIdFrom(args: Arguments<Options>, cmd = "dashboard", off
80
80
return { jobId, profile }
81
81
}
82
82
83
- export default async function dashboard ( args : Arguments < Options > ) {
83
+ export default async function dashboard ( args : Arguments < Options > , cmd : "db" | "dashboard" ) {
84
84
const { theme } = args . parsedOptions
85
85
86
86
const { demo } = args . parsedOptions
87
87
const scale = args . parsedOptions . s || 1
88
88
89
- const kind = args . argvNoOptions [ args . argvNoOptions . indexOf ( "dashboard" ) + 1 ] || "all"
90
- const { jobId, profile } = await jobIdFrom ( args )
89
+ const kind = args . argvNoOptions [ args . argvNoOptions . indexOf ( cmd ) + 1 ] || "all"
90
+ const { jobId, profile } = await jobIdFrom ( args , cmd )
91
91
92
92
if ( ! isValidKindA ( kind ) ) {
93
- throw new Error ( usage ( ) )
93
+ throw new Error ( usage ( cmd ) )
94
94
} else if ( ! jobId ) {
95
- throw new Error ( usage ( ) )
95
+ throw new Error ( usage ( cmd ) )
96
96
}
97
97
98
98
const gridFor = async ( kind : "status" | "cpu" | "memory" ) : Promise < GridSpec > => {
@@ -118,7 +118,7 @@ export default async function dashboard(args: Arguments<Options>) {
118
118
const db = dashboardUI ( profile , jobId , await gridForA ( kind ) , { scale } )
119
119
120
120
if ( ! db ) {
121
- throw new Error ( usage ( ) )
121
+ throw new Error ( usage ( cmd ) )
122
122
} else {
123
123
const { render } = await import ( "ink" )
124
124
0 commit comments