当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chalk.greenBright函数代码示例

本文整理汇总了TypeScript中chalk.greenBright函数的典型用法代码示例。如果您正苦于以下问题:TypeScript greenBright函数的具体用法?TypeScript greenBright怎么用?TypeScript greenBright使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了greenBright函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

	groupMap.forEach((commandMap, group) => {
		let groupOutput = `  ${chalk.greenBright(group)} ${createPadding(group, 8)}`;
		if (hasGroup) {
			groupOutput = `\n${groupOutput}`;
		}

		let hasCommand = false;
		const filteredCommandMap = [...commandMap.values()].filter(commandPredicate);
		filteredCommandMap.forEach((commandWrapper) => {
			const { name, description, default: isDefault } = commandWrapper;
			if (hasCommand) {
				groupOutput = `${groupOutput}\n${' '.repeat(11)}`;
			}
			groupOutput = `${groupOutput}  ${chalk.green(name)}`;
			groupOutput = `${groupOutput}${createPadding(name, 10)}`;
			groupOutput = `${groupOutput}  ${capitalize(description)}`;
			if (isDefault && showDefault && filteredCommandMap.length > 1) {
				groupOutput = `${groupOutput} (Default)`;
			}
			hasCommand = true;
			if (isDefault && showDefault) {
				commandOptionHelp = `\n${formatCommandOptions(commandWrapper)}`;
			}
		});
		if (hasCommand) {
			output = `${output}${groupOutput}`;
			hasGroup = true;
		}
	});
开发者ID:dojo,项目名称:cli,代码行数:29,代码来源:help.ts

示例2: getOptionDescription

		(key, options) => {
			let optionKeys = `${addOptionPrefix(chalk.greenBright(key))}`;
			if (options.alias) {
				const aliases = Array.isArray(options.alias) ? options.alias : [options.alias];
				optionKeys = aliases.reduce((result, alias) => {
					if (alias.length === 1) {
						return `${addOptionPrefix(chalk.greenBright(alias))}, ${result}`;
					}
					return `${result}, ${addOptionPrefix(chalk.greenBright(alias))}`;
				}, optionKeys);
			}
			commandOptionHelp = `${commandOptionHelp}\n  ${optionKeys}`;
			commandOptionHelp = `${commandOptionHelp} ${createPadding(optionKeys, 20)}`;
			const description = getOptionDescription(options);
			if (description) {
				commandOptionHelp = `${commandOptionHelp}${capitalize(description)}`;
			}
			if (options.choices) {
				commandOptionHelp = `${commandOptionHelp} [choices: "${options.choices
					.map((choice: any) => chalk.yellow(choice))
					.join('", "')}"]`;
			}
			if (options.default) {
				commandOptionHelp = `${commandOptionHelp} [default: "${chalk.yellow(options.default)}"]`;
			}
			if (options.type) {
				commandOptionHelp = `${commandOptionHelp} [type: "${chalk.yellow(options.type)}"]`;
			}
			if (isRequiredOption(options)) {
				commandOptionHelp = `${commandOptionHelp} [${chalk.yellow('required')}]`;
			}
		},
开发者ID:dojo,项目名称:cli,代码行数:32,代码来源:help.ts

示例3: start

async function start() {
  const logger = await Logger('Launcher')
  logger.info(chalk`========================================
{bold ${center(`Botpress Server`, 40)}}
{dim ${center(`Version ${sdk.version}`, 40)}}
{dim ${center(`OS ${process.distro.toString()}`, 40)}}
========================================`)

  global.printErrorDefault = err => {
    logger.attachError(err).error('Unhandled Rejection')
  }

  const modules: sdk.ModuleEntryPoint[] = []

  const globalConfig = await Config.getBotpressConfig()
  const loadingErrors: Error[] = []
  let modulesLog = ''

  const resolver = new ModuleResolver(logger)

  for (const entry of globalConfig.modules) {
    try {
      if (!entry.enabled) {
        modulesLog += os.EOL + `${chalk.dim('⊝')} ${entry.location} ${chalk.gray('(disabled)')}`
        continue
      }

      const moduleLocation = await resolver.resolve(entry.location)
      const rawEntry = resolver.requireModule(moduleLocation)

      const entryPoint = ModuleLoader.processModuleEntryPoint(rawEntry, entry.location)
      modules.push(entryPoint)
      process.LOADED_MODULES[entryPoint.definition.name] = moduleLocation
      modulesLog += os.EOL + `${chalk.greenBright('⦿')} ${entry.location}`
    } catch (err) {
      modulesLog += os.EOL + `${chalk.redBright('⊗')} ${entry.location} ${chalk.gray('(error)')}`
      loadingErrors.push(new FatalError(err, `Fatal error loading module "${entry.location}"`))
    }
  }

  logger.info(`Using ${chalk.bold(modules.length.toString())} modules` + modulesLog)

  for (const err of loadingErrors) {
    logger.attachError(err).error('Error starting Botpress')
  }

  if (loadingErrors.length) {
    process.exit(1)
  }

  await Botpress.start({ modules }).catch(err => {
    logger.attachError(err).error('Error starting Botpress')
    process.exit(1)
  })

  logger.info(`Botpress is ready at http://${process.HOST}:${process.PORT}/`)
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:57,代码来源:bootstrap.ts

示例4: start

async function start() {
  let currentEdition = BotpressEditions[process.BOTPRESS_EDITION] + ' Edition'

  if (process.BOTPRESS_EDITION === 'ce') {
    currentEdition = chalk.cyan(currentEdition)
  } else {
    currentEdition = chalk.yellow(currentEdition)
  }

  const logger = await Logger('Launcher')
  logger.info(chalk`========================================
{bold ${center(`Botpress Server - ${currentEdition}`, 40)}}
{dim ${center(`Version ${sdk.version}`, 40)}}
========================================`)

  global.printErrorDefault = err => {
    logger.attachError(err).error('Unhandled Rejection')
  }

  const modules: sdk.ModuleEntryPoint[] = []

  const globalConfig = await Config.getBotpressConfig()
  const loadingErrors: Error[] = []
  let modulesLog = ''

  const resolver = new ModuleResolver(logger)

  for (const entry of globalConfig.modules) {
    let originalRequirePaths: string[] = []

    try {
      if (!entry.enabled) {
        modulesLog += os.EOL + `${chalk.dim('⊝')} ${entry.location} ${chalk.gray('(disabled)')}`
        continue
      }

      const moduleLocation = await resolver.resolve(entry.location)

      // We bump temporarily bump the module's node_modules in priority
      // So that it loads the local versions of its own dependencies
      originalRequirePaths = global.require.getPaths()
      global.require.overwritePaths([
        path.join(moduleLocation, 'node_production_modules'),
        path.join(moduleLocation, 'node_modules'),
        ...originalRequirePaths
      ])
      const req = require(moduleLocation)
      global.require.overwritePaths(originalRequirePaths)
      originalRequirePaths = []

      const rawEntry = (req.default ? req.default : req) as sdk.ModuleEntryPoint
      const entryPoint = ModuleLoader.processModuleEntryPoint(rawEntry, entry.location)
      modules.push(entryPoint)
      process.LOADED_MODULES[entryPoint.definition.name] = moduleLocation
      modulesLog += os.EOL + `${chalk.greenBright('⦿')} ${entry.location}`
    } catch (err) {
      modulesLog += os.EOL + `${chalk.redBright('⊗')} ${entry.location} ${chalk.gray('(error)')}`
      loadingErrors.push(new FatalError(err, `Fatal error loading module "${entry.location}"`))
    } finally {
      if (originalRequirePaths.length) {
        global.require.overwritePaths(originalRequirePaths)
      }
    }
  }

  logger.info(`Using ${chalk.bold(modules.length.toString())} modules` + modulesLog)

  for (const err of loadingErrors) {
    logger.attachError(err).error('Error starting Botpress')
  }

  if (loadingErrors.length) {
    process.exit(1)
  }

  await Botpress.start({ modules })

  logger.info(`Botpress is ready at http://${process.HOST}:${process.PORT}/`)
}
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:79,代码来源:bootstrap.ts

示例5: formatHeader

function formatHeader(group: string = '<group>', command: string = '[<command>]') {
	return `${chalk.blueBright(dojoArt)}
${chalk.bold('Usage:')}

  $ ${chalk.greenBright('dojo')} ${chalk.greenBright(group)} ${chalk.green(command)} [<options>] [--help]`;
}
开发者ID:dojo,项目名称:cli,代码行数:6,代码来源:help.ts


注:本文中的chalk.greenBright函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。