How to use the @kui-shell/core.i18n function in @kui-shell/core

To help you get started, we’ve selected a few @kui-shell/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / kui / plugins / plugin-bash-like / src / lib / util / usage-helpers.ts View on Github external
*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { i18n } from '@kui-shell/core'
const strings = i18n('plugin-bash-like')

/**
 * A parameter that is a local file
 *
 */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const localFilepath: any[] = [{ name: 'path', docs: strings('localFilePath'), file: true, positional: true }]
github IBM / kui / plugins / plugin-bash-like / src / lib / cmds / bash-like.ts View on Github external
* This plugin introduces commands that dispatch to a local bash-like
 * shell
 *
 */

import Debug from 'debug'
import { exec, ExecOptions as ChildProcessExecOptions } from 'child_process'

import { inBrowser, Arguments, ExecOptions, ExecType, Registrar, i18n } from '@kui-shell/core'

import { handleNonZeroExitCode } from '../util/exec'
import { extractJSON } from '../util/json'
import { localFilepath } from '../util/usage-helpers'
import { dispatchToShell } from './catchall'

const strings = i18n('plugin-bash-like')
const debug = Debug('plugins/bash-like/cmds/general')

export const doExec = (
  cmdLine: string,
  execOptions: ExecOptions
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise> =>
  // eslint-disable-next-line no-async-promise-executor
  new Promise(async (resolve, reject) => {
    // purposefully imported lazily, so that we don't spoil browser mode (where shell is not available)

    const options: ChildProcessExecOptions = {
      maxBuffer: 1 * 1024 * 1024,
      env: Object.assign({}, process.env, execOptions['env'] || {})
    }
    if (process.env.SHELL) {
github IBM / kui / plugins / plugin-k8s / src / lib / controller / describe.ts View on Github external
* distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import Debug from 'debug'
import { safeDump } from 'js-yaml'

import { Commands, i18n, REPL, Tables, UI } from '@kui-shell/core'

import extractAppAndName from '../util/name'
// import { deleteResourceButton } from '../view/modes/crud'
import { KubeStatus, DefaultKubeStatus, KubeMetadata, DefaultKubeMetadata, KubeResource } from '../model/resource'

const strings = i18n('plugin-k8s')
const debug = Debug('k8s/controller/summary')

/**
 * Render a describe summary
 *
 */
const renderDescribe = async (
  command: string,
  getCmd: string,
  summaryCmd: string,
  resource: KubeResource,
  summary: Record,
  parsedOptions: Commands.ParsedOptions
) => {
  debug('renderDescribe', command, resource, summary)
github IBM / kui / plugins / plugin-manager / src / controller / compile.ts View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Registrar, UsageModel, eventBus, i18n } from '@kui-shell/core'

const strings = i18n('plugin-manager')

/**
 * Usage model for plugin remove
 *
 */
const usage: UsageModel = {
  strict: 'compile',
  command: 'compile',
  docs: strings('for advanced use: recompile plugin registry'),
  example: 'plugin compile',
  optional: [{ name: 'pluginToBeRemoved', positional: true }]
}

export default (commandTree: Registrar) => {
  commandTree.listen(
    '/plugin/compile',
github IBM / kui / plugins / plugin-manager / src / controller / version.ts View on Github external
*
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { join } from 'path'
import { lstat, readJSON } from 'fs-extra'

import { i18n, pluginUserHome, CodedError, Arguments, Registrar } from '@kui-shell/core'

const strings = i18n('plugin-manager')

interface Version {
  name: string
  version: string
  installedOn: Date
}

/**
 * Read the package.json of one given plugin to get its version
 *
 */
const _getVersion = async (pluginDir: string): Promise => {
  try {
    const { name, version } = (await readJSON(join(pluginDir, 'package.json'))) as { name: string; version: string }
    const { ctime } = await lstat(pluginDir)
github IBM / kui / plugins / plugin-core-support / about / src / usage.ts View on Github external
*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { i18n } from '@kui-shell/core'
const strings = i18n('plugin-core-support')

export default {
  version: {
    strict: 'version',
    command: 'version',
    title: strings('versionUsageTitle'),
    header: strings('versionUsageHeader'),
    example: 'version'
  }
}
github IBM / kui / plugins / plugin-core-support / src / lib / cmds / confirm.ts View on Github external
* limitations under the License.
 */

import {
  Registrar,
  ExecType,
  UsageModel,
  eventBus,
  i18n,
  getCurrentPrompt,
  injectCSS,
  KeyCodes,
  Tab
} from '@kui-shell/core'

const strings = i18n('plugin-core-support')

const usage: UsageModel = {
  command: 'confirm',
  strict: 'confirm',
  example: 'confirm [--asking ] ',
  docs: 'Confirmation Modal',
  optional: [
    {
      name: '--asking',
      docs: strings('confirmationMessage')
    }
  ],
  required: [
    {
      name: 'command',
      docs: strings('commandToBeExecuted')
github IBM / kui / plugins / plugin-manager / src / controller / home.ts View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { isHeadless, Registrar, i18n, UsageModel, pluginUserHome } from '@kui-shell/core'

const strings = i18n('plugin-manager')

const usage: UsageModel = {
  docs: strings('the home directory for user-installed plugins')
}

export default function(commandTree: Registrar) {
  commandTree.listen(
    '/plugin/home',
    async ({ REPL }) => {
      const home = await pluginUserHome()

      if (isHeadless()) {
        return home
      } else {
        const link = document.createElement('div')
        link.classList.add('clickable')
github IBM / kui / plugins / plugin-manager / src / controller / install.ts View on Github external
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as Debug from 'debug'
import { ensureDir, symlink, unlink } from 'fs-extra'
import { basename, join } from 'path'
import { execFile, spawn } from 'child_process'

import { userDataDir, exportSettingsTo, i18n, Arguments, Registrar, UsageModel } from '@kui-shell/core'

import Ora from '../util/ora'
import locateNpm from '../util/locate-npm'

const strings = i18n('plugin-manager')
const debug = Debug('plugins/plugin-manager/cmd/install')

/**
 * Usage model for plugin install
 *
 */
const usage: UsageModel = {
  strict: 'install',
  command: 'install',
  breadcrumb: strings('Install plugin'),
  docs: strings('install a plugin'),
  example: 'plugin install ',
  detailedExample: {
    command: 'plugin install @kui-shell/plugin-sample',
    docs: strings('a simple example plugin')
  },
github IBM / kui / plugins / plugin-manager / src / controller / commands.ts View on Github external
* you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Arguments, Registrar, i18n, commandsOfferedByPlugin, Table } from '@kui-shell/core'
import { installedPlugin } from '../util/usage-common'

const strings = i18n('plugin-manager')

const usage = {
  strict: 'commands',
  command: 'commands',
  breadcrumb: strings('offered commands'),
  docs: strings('list commands offered by an installed shell plugin'),
  example: 'plugin commands ',
  required: installedPlugin,
  related: ['plugin install', 'plugin list']
}

const doList = ({ argvNoOptions }: Arguments): Promise => {
  const plugin = argvNoOptions[argvNoOptions.indexOf('commands') + 1]
  return commandsOfferedByPlugin(plugin)
}
<table></table>