@@ -2,11 +2,13 @@ import {renderTable, ScCommand, ScConnection, sleep} from '@dishantlangayan/sc-c
22import { Flags } from '@oclif/core'
33import { MultiBar , Presets , SingleBar } from 'cli-progress'
44
5+ import { resolveOrgConnection } from '../../../lib/org-utils.js'
56import {
67 EventBrokerAllOperationsApiResponse ,
78 EventBrokerListApiResponse ,
89 EventBrokerOperationApiResponse ,
910 EventBrokerOperationDetail ,
11+ ProgressLog ,
1012} from '../../../types/broker.js'
1113
1214export default class MissionctrlBrokerOpstatus extends ScCommand < typeof MissionctrlBrokerOpstatus > {
@@ -18,6 +20,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
1820 static override examples = [
1921 '<%= config.bin %> <%= command.id %> -b <broker-id>' ,
2022 '<%= config.bin %> <%= command.id %> -n <broker-name>' ,
23+ '<%= config.bin %> <%= command.id %> --org=my-org -b <broker-id>' ,
2124 ]
2225 static override flags = {
2326 'broker-id' : Flags . string ( {
@@ -30,6 +33,10 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
3033 description : 'Name of the event broker service.' ,
3134 exactlyOne : [ 'broker-id' , 'name' ] ,
3235 } ) ,
36+ org : Flags . string ( {
37+ char : 'o' ,
38+ description : 'Organization ID or alias to use. If not specified, uses the default organization.' ,
39+ } ) ,
3340 'show-progress' : Flags . boolean ( {
3441 char : 'p' ,
3542 description :
@@ -50,7 +57,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
5057 const showProgress = flags [ 'show-progress' ] ?? false
5158 const waitMs = flags [ 'wait-ms' ] ?? 5000
5259
53- const conn = new ScConnection ( )
60+ const conn = await resolveOrgConnection ( this , flags . org )
5461
5562 // Base API url
5663 let apiUrl : string = `/missionControl/eventBrokerServices`
@@ -119,7 +126,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
119126 // start a new progress bar for the operation with a total value of size of the steps
120127 const progressBar = multiProgressBar . create ( numSteps , 0 , { operationType : operationData . operationType } )
121128 // Update the progress with the steps completed
122- const completedNumSteps = opStatusResp . data . progressLogs . filter ( ( log ) => log . status === 'success' ) . length
129+ const completedNumSteps = opStatusResp . data . progressLogs . filter ( ( log : ProgressLog ) => log . status === 'success' ) . length
123130 progressBar . update ( completedNumSteps )
124131 if (
125132 completedNumSteps === numSteps ||
@@ -170,7 +177,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
170177 const opStatusResp = await conn . get < EventBrokerOperationApiResponse > ( opStatusApiUrl )
171178 if ( opStatusResp . data . progressLogs ) {
172179 const numSteps = opStatusResp . data . progressLogs . length
173- const completedNumSteps = opStatusResp . data . progressLogs . filter ( ( log ) => log . status === 'success' ) . length
180+ const completedNumSteps = opStatusResp . data . progressLogs . filter ( ( log : ProgressLog ) => log . status === 'success' ) . length
174181 // Update progress bar
175182 progressBar . setTotal ( numSteps )
176183 progressBar . update ( completedNumSteps )
0 commit comments