1414 * limitations under the License.
1515 */
1616
17- import { Arguments , CommandOptions , Registrar } from "@kui-shell/core"
17+ import { Arguments , CommandOptions , Registrar , encodeComponent , unparse } from "@kui-shell/core"
1818
1919import "../../web/scss/components/Dashboard/_index.scss"
2020
@@ -23,22 +23,31 @@ export interface FollowOptions {
2323 follow : boolean
2424}
2525
26+ type DashboardOptions = FollowOptions & {
27+ a : boolean
28+ attach : boolean
29+ }
30+
2631export const followFlags : CommandOptions [ "flags" ] = {
27- boolean : [ "f" , "follow" ] ,
28- alias : { follow : [ "f" ] } ,
32+ boolean : [ "f" , "follow" , "a" , "attach" ] ,
33+ alias : { follow : [ "f" ] , attach : [ "a" ] } ,
2934}
3035
31- function dashboardcli ( args : Arguments ) {
36+ function dashboardcli ( args : Arguments < DashboardOptions > ) {
37+ if ( args . parsedOptions . attach ) {
38+ // attach to a running job
39+ return import ( "./attach" ) . then ( ( _ ) => _ . default ( args ) )
40+ }
41+
3242 const filepath = args . argvNoOptions [ 1 ]
3343 if ( ! filepath ) {
3444 throw new Error ( "Usage: codeflare dashboard <filepath>" )
3545 }
3646
37- const restIdx = args . command . indexOf ( "dashboard" ) + "dashboard" . length
38- return args . REPL . qexec ( `codeflare dashboardui ${ args . command . slice ( restIdx ) } ` )
47+ return args . REPL . qexec ( `codeflare dashboardui ${ encodeComponent ( filepath ) } ${ unparse ( args . parsedOptions ) } ` )
3948}
4049
41- async function dashboardui ( args : Arguments < FollowOptions > ) {
50+ async function dashboardui ( args : Arguments < DashboardOptions > ) {
4251 const { setTabReadonly } = await import ( "@kui-shell/plugin-madwizard" )
4352 setTabReadonly ( args )
4453
@@ -52,8 +61,10 @@ async function dashboardui(args: Arguments<FollowOptions>) {
5261export default function registerDashboardCommands ( registrar : Registrar ) {
5362 const flags = followFlags
5463
55- registrar . listen ( "/dashboard" , dashboardcli , { flags, outputOnly : true } )
64+ ; [ "dashboard" , "db" ] . forEach ( ( db ) => registrar . listen ( `/${ db } ` , dashboardcli , { flags, outputOnly : true } ) )
65+
5666 registrar . listen ( "/codeflare/dashboardui" , dashboardui , {
67+ hidden : true ,
5768 needsUI : true ,
5869 outputOnly : true ,
5970 flags,
0 commit comments