import { Arguments , Capabilities , Registrar , i18n } from '@kui-shell/core' ; import { doExecWithPty , doExecWithMarkdown , isUsage , doHelp , KubeOptions } from '@kui-shell/plugin-kubectl' ; const strings = i18n ( 'plugin-kubectl' ) ; /** is the given string `str` the `oc` or `odo` command? */ const isOc = ( str ) => /^(oc|odo)$/ . test ( str ) ; export default ( registrar ) => { if ( Capabilities . inBrowser ( ) && ! Capabilities . hasProxy ( ) ) { return ; } registrar . catchall ( ( argv ) => isOc ( argv [ 0 ] ) , async ( args ) => { const cmd = args . argv [ 0 ] ; if ( args . argv . length === 1 || ( args . argv . length === 2 && args . argv [ 1 ] === cmd ) ) { const response = await doExecWithMarkdown ( args , cmd ) ; response . links . push ( { label : strings ( 'More Information' ) , command : `${ cmd } -h` } ) ; return response ; } return isUsage ( args ) ? doHelp ( cmd , args ) . catch ( err => { console . error ( err ) ; return doExecWithPty ( args ) ; } ) : doExecWithPty ( args ) ; } , 1 ) ; } ;