import { Registrar } from '@kui-shell/core' ; import { defaultFlags , doGet , doExecWithStdout , emitKubectlConfigChangeEvent } from '@kui-shell/plugin-kubectl' ; export default function registerOcProjectGet ( registrar ) { registrar . listen ( '/oc/project' , async ( args ) => { const response = await doExecWithStdout ( args , undefined , 'oc' ) ; const newNamespace = args . argvNoOptions [ args . argvNoOptions . indexOf ( 'project' ) + 1 ] ; if ( newNamespace ) { emitKubectlConfigChangeEvent ( 'SetNamespaceOrContext' , newNamespace ) ; } return response ; } ) ; registrar . listen ( '/oc/projects' , args => args . REPL . qexec ( 'oc get projects' , undefined , undefined , args . execOptions ) , defaultFlags ) ; const aliases = [ 'project' , 'projects' , 'ns' , 'namespace' , 'namespaces' ] ; aliases . forEach ( ns => { registrar . listen ( `/oc/get/${ ns }` , doGet ( 'oc' ) , defaultFlags ) ; } ) ; }