How to use @oclif/parser - 10 common examples

To help you get started, we’ve selected a few @oclif/parser 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 oclif / command / src / flags.ts View on Github external
export const version = (opts: Partial> = {}) => {
  return Parser.flags.boolean({
    // char: 'v',
    description: 'show CLI version',
    ...opts,
    parse: (_: any, cmd: Command) => {
      cmd.log(cmd.config.userAgent)
      cmd.exit(0)
    },
  })
}
export const help = (opts: Partial> = {}) => {
github che-incubator / chectl / src / commands / server / update.ts View on Github external
options: ['helm', 'operator', 'minishift-addon'],
      default: ''
    }),
    platform: string({
      char: 'p',
      description: 'Type of Kubernetes platform. Valid values are \"minikube\", \"minishift\", \"k8s (for kubernetes)\", \"openshift\", \"crc (for CodeReady Containers)\", \"microk8s\".',
      options: ['minikube', 'minishift', 'k8s', 'openshift', 'microk8s', 'docker-desktop', 'crc'],
    }),
    chenamespace: cheNamespace,
    templates: string({
      char: 't',
      description: 'Path to the templates folder',
      default: Update.getTemplatesDir(),
      env: 'CHE_TEMPLATES_FOLDER'
    }),
    'che-operator-image': string({
      description: 'Container image of the operator. This parameter is used only when the installer is the operator',
      default: DEFAULT_CHE_OPERATOR_IMAGE
    }),
    'skip-version-check': boolean({
      description: 'Skip user confirmation on version check',
      default: false
    }),
    'deployment-name': cheDeployment,
    'listr-renderer': listrRenderer,
    help: flags.help({ char: 'h' }),
  }

  static getTemplatesDir(): string {
    // return local templates folder if present
    const TEMPLATES = 'templates'
    const templatesDir = path.resolve(TEMPLATES)
github netlify / cli / src / utils / command.js View on Github external
}
    }
    if (!opts.flags.auth) {
      globalFlags['auth'] = {
        parse: (b, _) => b,
        description: 'Netlify auth token',
        input: [],
        multiple: false,
        type: 'option'
      }
    }

    // enrich with flags here
    opts.flags = Object.assign({}, opts.flags, globalFlags)

    return require('@oclif/parser').parse(
      argv,
      Object.assign(
        {},
        {
          context: this
        },
        opts
      )
    )
  }
github che-incubator / chectl / src / commands / server / update.ts View on Github external
char: 'p',
      description: 'Type of Kubernetes platform. Valid values are \"minikube\", \"minishift\", \"k8s (for kubernetes)\", \"openshift\", \"crc (for CodeReady Containers)\", \"microk8s\".',
      options: ['minikube', 'minishift', 'k8s', 'openshift', 'microk8s', 'docker-desktop', 'crc'],
    }),
    chenamespace: cheNamespace,
    templates: string({
      char: 't',
      description: 'Path to the templates folder',
      default: Update.getTemplatesDir(),
      env: 'CHE_TEMPLATES_FOLDER'
    }),
    'che-operator-image': string({
      description: 'Container image of the operator. This parameter is used only when the installer is the operator',
      default: DEFAULT_CHE_OPERATOR_IMAGE
    }),
    'skip-version-check': boolean({
      description: 'Skip user confirmation on version check',
      default: false
    }),
    'deployment-name': cheDeployment,
    'listr-renderer': listrRenderer,
    help: flags.help({ char: 'h' }),
  }

  static getTemplatesDir(): string {
    // return local templates folder if present
    const TEMPLATES = 'templates'
    const templatesDir = path.resolve(TEMPLATES)
    const exists = fs.pathExistsSync(templatesDir)
    if (exists) {
      return TEMPLATES
    }
github che-incubator / chectl / src / commands / workspace / inject.ts View on Github external
static flags = {
    help: flags.help({ char: 'h' }),
    kubeconfig: flags.boolean({
      char: 'k',
      description: 'Inject the local Kubernetes configuration'
    }),
    workspace: string({
      char: 'w',
      description: 'Target workspace. Can be omitted if only one Workspace is running'
    }),
    container: string({
      char: 'c',
      description: 'Target container. If not specified, configuration files will be injected in all containers of a Che Workspace pod',
      required: false
    }),
    'kube-context': string({
      description: 'Kubeconfig context to inject',
      required: false
    }),
    chenamespace: cheNamespace,
    'listr-renderer': listrRenderer
  }

  async run() {
    const { flags } = this.parse(Inject)
    const notifier = require('node-notifier')
    const cheTasks = new CheTasks(flags)

    const tasks = new Listr([], { renderer: flags['listr-renderer'] as any })
    tasks.add(cheTasks.verifyCheNamespaceExistsTask(flags, this))
    tasks.add(cheTasks.verifyWorkspaceRunTask(flags, this))
    tasks.add([
github che-incubator / chectl / src / commands / server / start.ts View on Github external
export default class Start extends Command {
  static description = 'start Eclipse Che Server'

  static flags = {
    help: flags.help({ char: 'h' }),
    chenamespace: cheNamespace,
    'listr-renderer': listrRenderer,
    'deployment-name': cheDeployment,
    cheimage: string({
      char: 'i',
      description: 'Che server container image',
      default: DEFAULT_CHE_IMAGE,
      env: 'CHE_CONTAINER_IMAGE'
    }),
    templates: string({
      char: 't',
      description: 'Path to the templates folder',
      default: Start.getTemplatesDir(),
      env: 'CHE_TEMPLATES_FOLDER'
    }),
    'devfile-registry-url': string({
      description: 'The URL of the external Devfile registry.',
      env: 'CHE_WORKSPACE_DEVFILE__REGISTRY__URL'
    }),
    'plugin-registry-url': string({
      description: 'The URL of the external plugin registry.',
      env: 'CHE_WORKSPACE_PLUGIN__REGISTRY__URL'
    }),
    cheboottimeout: string({
      char: 'o',
      description: 'Che server bootstrap timeout (in milliseconds)',
github che-incubator / chectl / src / common-flags.ts View on Github external
import { string } from '@oclif/parser/lib/flags'

export const cheNamespace = string({
  char: 'n',
  description: 'Kubernetes namespace where Che server is supposed to be deployed',
  default: 'che',
  env: 'CHE_NAMESPACE'
})

export const cheDeployment = string({
  description: 'Che deployment name',
  default: 'che',
  env: 'CHE_DEPLOYMENT'
})

export const listrRenderer = string({
  description: 'Listr renderer',
  options: ['default', 'silent', 'verbose'],
  default: 'default'
})

export const accessToken = string({
  description: 'Che OIDC Access Token',
  env: 'CHE_ACCESS_TOKEN'
})
github che-incubator / chectl / src / commands / devfile / generate.ts View on Github external
static description = 'generate and print a devfile to stdout given some Kubernetes resources and other Che workspaces features (project, language-support, commands etc...)'

  static flags = {
    help: flags.help({ char: 'h' }),
    name: string({
      description: 'Workspace name',
      default: '',
      env: 'WSNAME',
      required: false,
    }),
    dockerimage: string({
      description: 'dockerimage component to include in the Devfile',
      env: 'DOCKERIMAGE',
      required: false,
    }),
    namespace: string({
      description: 'Kubernetes namespace where the resources are defined',
      default: '',
      env: 'NAMESPACE',
      required: false,
    }),
    editor: string({
      description: `Specify the Che editor component. Currently supported editors: ${editors}`,
      env: 'EDITOR',
      required: false,
    }),
    selector: string({
      description: 'label selector to filter the Kubernetes resources. For example --selector="app.kubernetes.io/name=employee-manager"',
      env: 'SELECTOR',
      required: false,
    }),
    language: string({
github che-incubator / chectl / src / commands / devfile / generate.ts View on Github external
selector: string({
      description: 'label selector to filter the Kubernetes resources. For example --selector="app.kubernetes.io/name=employee-manager"',
      env: 'SELECTOR',
      required: false,
    }),
    language: string({
      description: `Add support for a particular language. Currently supported languages: ${languages}`,
      env: 'LANGUAGE_SUPPORT',
      required: false,
    }),
    plugin: string({
      description: 'Che plugin to include in the workspace. The format is JSON. For example this is a valid Che Plugin specification: {"type": "TheEndpointName.ChePlugin", "alias": "java-ls", "id": "redhat/java/0.38.0"}',
      env: 'CHE_PLUGIN',
      required: false,
    }),
    'git-repo': string({
      description: 'Source code git repository to include in the workspace',
      env: 'GIT_REPO',
      required: false,
    }),
    command: string({
      description: 'Command to include in the workspace',
      env: 'COMMAND',
      required: false,
    }),
  }

  async run() {
    const { flags } = this.parse(Generate)
    kube = new KubeHelper(flags)
    const notifier = require('node-notifier')
github che-incubator / chectl / src / common-flags.ts View on Github external
env: 'CHE_NAMESPACE'
})

export const cheDeployment = string({
  description: 'Che deployment name',
  default: 'che',
  env: 'CHE_DEPLOYMENT'
})

export const listrRenderer = string({
  description: 'Listr renderer',
  options: ['default', 'silent', 'verbose'],
  default: 'default'
})

export const accessToken = string({
  description: 'Che OIDC Access Token',
  env: 'CHE_ACCESS_TOKEN'
})

@oclif/parser

arg and flag parser for oclif

MIT
Latest version published 8 months ago

Package Health Score

53 / 100
Full package analysis