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


TypeScript nopt类代码示例

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


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

示例1: parseArgs

function parseArgs() {
  return nopt(
    {
      "help": Boolean,
      "version": Boolean,
      "verbose": Boolean,
      "port": Number,
      "examples": Boolean,
      "example": String, // deprecated
      "config": String,

      "print-config": Boolean,
      "with-comments": Boolean,

      "file": String,
      "druid": String,
      "postgres": String,
      "mysql": String,

      "user": String,
      "password": String,
      "database": String
    },
    {
      "v": ["--verbose"],
      "p": ["--port"],
      "c": ["--config"],
      "f": ["--file"],
      "d": ["--druid"]
    },
    process.argv
  );
}
开发者ID:RaviNK,项目名称:pivot,代码行数:33,代码来源:config.ts

示例2: if

    operations.push(async callback => {
        var module = remain[0]

        if (cooked[0] === '--version' || cooked[0] === '-v') {
            module = 'version'
        } else if (!remain.length || cooked.indexOf('-h') >= 0 || cooked.indexOf('--help') >= 0) {
            module = 'help'
        }

        try {
            Command = await loadCommand(module)
        } catch (err) {
            throw new Error(`Cannot find module ${module}\n${err}`)
        }

        options = nopt(Command.DETAILS.options, Command.DETAILS.shorthands, process.argv, 2)

        iterative = Command.DETAILS.iterative

        cooked = options.argv.cooked
        remain = options.argv.remain

        options.number = options.number || [remain[1]]
        options.remote = options.remote || config.default_remote

        if (module === 'help') {
            callback()
        } else {
            User.login(callback)
        }
    })
开发者ID:gamerson,项目名称:gh,代码行数:31,代码来源:cmd.ts

示例3: parseArgs

function parseArgs() {
  return nopt(
    {
      "host": String,
      "druid": String,
      "data-source": String,
      "help": Boolean,
      "query": String,
      "interval": String,
      "version": Boolean,
      "verbose": Boolean,
      "timeout": Number,
      "retry": Number,
      "concurrent": Number,
      "output": String,
      "allow": [String, Array],
      "force-unique": [String, Array],
      "force-histogram": [String, Array],
      "skip-cache": Boolean,
      "introspection-strategy": String
    },
    {
      "h": ["--host"],
      "q": ["--query"],
      "v": ["--verbose"],
      "d": ["--data-source"],
      "i": ["--interval"],
      "a": ["--allow"],
      "r": ["--retry"],
      "c": ["--concurrent"],
      "o": ["--output"],
      "fu": ["--force-unique"],
      "fh": ["--force-histogram"]
    },
    process.argv
  );
}
开发者ID:dkarpman,项目名称:plyql,代码行数:37,代码来源:cli.ts

示例4: Help

export default function Help() {
    this.options = nopt(Help.DETAILS.options, Help.DETAILS.shorthands, process.argv, 2)
}
开发者ID:gamerson,项目名称:gh,代码行数:3,代码来源:help.ts

示例5: setUp

export function setUp() {
    let Command
    let iterative
    let options
    const operations = []
    const parsed = nopt(process.argv)
    let remain = parsed.argv.remain
    let cooked = parsed.argv.cooked

    operations.push(callback => {
        checkVersion()

        callback()
    })

    operations.push(async callback => {
        var module = remain[0]

        if (cooked[0] === '--version' || cooked[0] === '-v') {
            module = 'version'
        } else if (!remain.length || cooked.indexOf('-h') >= 0 || cooked.indexOf('--help') >= 0) {
            module = 'help'
        }

        try {
            Command = await loadCommand(module)
        } catch (err) {
            throw new Error(`Cannot find module ${module}\n${err}`)
        }

        options = nopt(Command.DETAILS.options, Command.DETAILS.shorthands, process.argv, 2)

        iterative = Command.DETAILS.iterative

        cooked = options.argv.cooked
        remain = options.argv.remain

        options.number = options.number || [remain[1]]
        options.remote = options.remote || config.default_remote

        if (module === 'help') {
            callback()
        } else {
            User.login(callback)
        }
    })

    async.series(operations, async () => {
        let iterativeValues
        const remoteUrl = git.getRemoteUrl(options.remote)

        options.isTTY = {}
        options.isTTY.in = Boolean(process.stdin.isTTY)
        options.isTTY.out = Boolean(process.stdout.isTTY)
        options.loggedUser = getUser()
        options.remoteUser = git.getUserFromRemoteUrl(remoteUrl)

        if (!options.user) {
            if (options.repo || options.all) {
                options.user = options.loggedUser
            } else {
                options.user = process.env.GH_USER || options.remoteUser || options.loggedUser
            }
        }

        options.repo = options.repo || git.getRepoFromRemoteURL(remoteUrl)
        options.currentBranch = options.currentBranch || git.getCurrentBranch()

        expandAliases(options)
        options.github_host = config.github_host
        options.github_gist_host = config.github_gist_host

        // Try to retrieve iterative values from iterative option key,
        // e.g. option['number'] === [1,2,3]. If iterative option key is not
        // present, assume [undefined] in order to initialize the loop.
        iterativeValues = options[iterative] || [undefined]

        iterativeValues.forEach(async value => {
            options = clone(options)

            // Value can be undefined when the command doesn't have a iterative
            // option.
            options[iterative] = value

            invokePayload(options, Command, cooked, remain)

            if (process.env.NODE_ENV === 'testing') {
                const { prepareTestFixtures } = await import('./utils')

                await new Command(options).run(prepareTestFixtures(Command.name, cooked))
            } else {
                await new Command(options).run()
            }
        })
    })
}
开发者ID:gamerson,项目名称:gh,代码行数:96,代码来源:cmd.ts


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