• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript commander.help函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: function

export default function (args:string[]):void {
  let watch: Watch = new Watch();
    program.version(pkg.version);

    program.command('watch', '')
    .description('watch file change run command')
    .option('-c, --config [config]', 'config file')
    .option('-t, --test [testFile]', 'test mode')
    .action(watch.run.bind(watch));

    program.command('config', '')
    .description('create and test config file')
    .option('-i, --init [config]', 'create config file')
    .option('-t, --test [config]', 'test config file')
    .action(configUtil.action.bind(configUtil));

    program.command('run', '')
    .description('run command by config')
    .option('-f, --file <file>', 'run command by file')
    .option('-o, --stdout', 'run command by stdout file')
    .action(watch.compile.bind(watch));

    program.parse(args);

    if(!process.argv.slice(2).length) {
      program.help();
    }
}
开发者ID:thinkjs,项目名称:autocommand-cli,代码行数:28,代码来源:command.ts


示例2: main

async function main() {
  program.command('ls').action(async () => {
    const torrents = await (await getClient()).list()
    if (torrents.length === 0) {
      console.info('no torrents')
      return
    }
    torrents.forEach(t => console.info(formatTorrent(t)))
  })

  program.command('remove-complete').action(async () => {
    const torrents = await (await getClient()).removeComplete()
    if (torrents.length === 0) {
      console.info('No complete torrents to remove')
    } else {
      console.info(`Removed ${torrents.length} torrents:`)
      torrents.forEach(t => console.info(formatTorrent(t)))
    }
  })

  program.command('add-magnet <link>').action(async (link: string) => {
    const result = await (await getClient()).addMagnet(link)
    console.info(result)
  })

  program.parse(process.argv)

  if (process.argv.length === 2) program.help()
}
开发者ID:elentok,项目名称:dotfiles,代码行数:29,代码来源:bt-cli.ts


示例3: generateStream

(async () => {
  if (!fileGlob) return program.help();
  const root = process.cwd();
  const outFile = program['outFile'];

  const globToUse =
    path.resolve(fileGlob) === fileGlob ? fileGlob : path.join(CWD, fileGlob);

  const log = console.log;
  if (!outFile) (console as any).log = () => {};
  await Tyr.config({ validate: [{ glob: globToUse }] });
  if (!outFile) console.log = log;

  const stream = generateStream(Tyr.collections, {
    type: program.type || 'isomorphic'
  });

  if (outFile) {
    const filename = path.join(root, outFile);
    stream.pipe(
      fs.createWriteStream(filename).on('finish', () => {
        process.exit(0);
      })
    );
  } else {
    stream.pipe(process.stdout);
    stream.on('end', () => {
      process.exit(0);
    });
  }
})().catch(err => {
开发者ID:tyranid-org,项目名称:tyranid,代码行数:31,代码来源:cli.ts


示例4: CliCreateEmbedToken

export default function CliCreateEmbedToken() {
    let pkg = require('../package.json');

    function list(val) {
        return val.split(',');
    }

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-w, --workspace <workspaceId>', 'The Power BI workspace id')
        .option('-r, --report <reportId>', 'The Power BI report id')
        .option('-d, --dataset <datasetId>', 'The Power BI dataset id')
        .option('-s, --scopes [scopes]', 'The permission scopes allowed')
        .option('-u, --username [username]', 'The RLS username')
        .option('--roles [roles]', 'The RLS roles', list)
        .option('-e, --expiration <expiration>', 'The token expiration date');

    program.on('--help', function () {
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi create-embed-token -c <collection>, -w <workspace> -r <reportId> -k <accessKey> -u [username] --roles [roles1,roles2,...]');
        console.log('    $ powerbi create-embed-token -c <collection>, -w <workspace> -r <reportId> -k <accessKey> -s [scopes]');
        console.log('    $ powerbi create-embed-token -c <collection>, -w <workspace> -d <datasetId> -k <accessKey> -s [scopes]');
        console.log('    Create report in embedded view needs the following scopes: "Dataset.Read Workspace.Report.Create"');
    });

    program.parse(process.argv);

    let settings = config.merge(program);

    if (!(settings.collection && settings.accessKey)) {
        program.help();
    } else {
        try {
            let token: powerbi.PowerBIToken = null;

            if (!settings.accessKey) {
                return cli.error('Access key param is required');
            }

            if (!(settings.collection && settings.workspace)) {
                return cli.error('collection and workspace params are required');
            }

            if (!(settings.report || settings.dataset)) {
                return cli.error('Either reportId or datasetId must be set');
            }
            let expiration = settings.expiration ? new Date(settings.expiration) : void 0;
            token = powerbi.PowerBIToken.createReportEmbedToken(settings.collection, settings.workspace, settings.report, settings.dataset, settings.scopes, settings.username, settings.roles, expiration);

            let jwt = token.generate(settings.accessKey);
            cli.success('Embed Token: ', jwt);

        } catch (err) {
            cli.error(err);
        }
    }
}
开发者ID:Microsoft,项目名称:PowerBI-Cli,代码行数:59,代码来源:cli-create-embed-token.ts


示例5: CliCloneReprot

export default function CliCloneReprot() {
    let pkg = require('../package.json');

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-w, --workspace <workspace>', 'The Power BI workspace')
        .option('-r, --report <reportKey>', 'The report to clone')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-n, --newName <newName>', 'The new report name')
        .option('-t, --tworkspace [targetWorkspace]', 'New target workspace to save report in. default is original report workspace.')
        .option('-d, --tdataset [targetDatasetKey]', 'New target dataset to rebind report with. default is original report dataset.')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Description:');
        console.log('');
        console.log('    Clones a report and gives name to new report.');
        console.log('    Assign target workspace to save the new report in a specific workspace.');
        console.log('    Assign target dataset to rebind the new report with a specific dataset.');
        console.log('    When moving between workspaces, the dataset has to reside within the targeted workspace.');
        console.log('');
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi clone-report -c <collection> -w <workspace> -k <accessKey> -r <report> -n <newName>');
    });

    program.parse(process.argv);

    let settings = config.merge(program);

    if (!(settings.collection && settings.accessKey && settings.workspace && settings.report && settings.newName)) {
        program.help();
    }

    try {
        let credentials = new msrest.TokenCredentials(settings.accessKey, 'AppKey');
        let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

        let params: powerbi.CloneReportRequest = {
            name: settings.newName,
            targetWorkspaceId: settings.tworkspace,
            targetModelId: settings.tdataset
        };

        client.reports.cloneReport(settings.collection, settings.workspace, settings.report, params, (err, result) => {
            if (err) {
                return cli.error(err);
            }
            
            cli.print('New report ID: %s', result.id);
            cli.print('Name: %s', result.name);
            cli.print('EmbedUrl: %s', result.embedUrl);
            
            cli.success('Clone report has been completed successfully');
        });
    } catch (err) {
        cli.error(err);
    }
}
开发者ID:Microsoft,项目名称:PowerBI-Cli,代码行数:59,代码来源:cli-clone-report.ts


示例6: CliGetReports

export default function CliGetReports() {
    let err;
    let program = require('commander');
    let colors = require('colors');
    let pkg = require('../package.json');
    let util = require('util');

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-w, --workspace <workspace>', 'The Power BI workspace')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi get-reports -c <collection> -w <workspace> -k <accessKey>');
    });

    program.parse(process.argv);

    let settings = config.merge(program);

    if (!(settings.collection && settings.accessKey && settings.workspace)) {
        program.help();
    } else {
        try {
            let token = powerbi.PowerBIToken.createDevToken(settings.collection, settings.workspace);
            let credentials = new msrest.TokenCredentials(token.generate(settings.accessKey), 'AppToken');
            let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

            client.reports.getReports(settings.collection, settings.workspace, (err, result) => {
                if (err) {
                    return cli.error(err);
                }
                
                let reports = result.value;

                if (reports.length === 0) {
                    return cli.warn('No reports found within workspace: %s', settings.workspace);
                }

                cli.print('=========================================');
                cli.print('Gettings reports for Collection: %s', settings.workspace);
                cli.print('=========================================');

                reports.forEach(report => {
                    cli.print('ID: %s | Name: %s', report.id, report.name);
                });
            });
        } catch (err) {
            cli.error(err);
        }
    }
}
开发者ID:llenroc,项目名称:PowerBI-Cli,代码行数:55,代码来源:cli-get-reports.ts


示例7: CliGetWorkspaces

export default function CliGetWorkspaces() {
    let err;
    let program = require('commander');
    let colors = require('colors');
    let pkg = require('../package.json');
    let util = require('util');

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi get-workspaces -c <collection> -k <accessKey>');
    });

    program.parse(process.argv);
    let settings = config.merge(program);

    if (!(settings.collection && settings.accessKey)) {
        program.help();
    } else {
        try {
            let token = powerbi.PowerBIToken.createProvisionToken(settings.collection);
            let credentials = new msrest.TokenCredentials(token.generate(settings.accessKey), 'AppToken');
            let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

            client.workspaces.getWorkspacesByCollectionName(settings.collection, (err, result) => {
                if (err) {
                    return cli.error(err);
                }
                
                let workspaces = result.value;

                if (workspaces.length == 0) {
                    return cli.warn('No workspaces found within collection: %s', settings.collection);
                }

                cli.print("================================================");
                cli.print('Gettings workspaces for Collection: %s', settings.collection);
                cli.print("================================================");

                result.value.forEach(workspace => {
                    cli.print(workspace.workspaceId);
                });
            });
        } catch (_error) {
            err = _error;
            cli.error(err);
        }
    }
}
开发者ID:llenroc,项目名称:PowerBI-Cli,代码行数:54,代码来源:cli-get-workspaces.ts


示例8: callGenerate

    .action(function (file: any)
    {
        if (!metadataurlValue)
            program.help();
        var serviceurl = program["url"];
        var proxyname = program["proxyname"];

        console.log('metadataurl: %s', metadataurlValue);
        console.log('serviceurl: %s', serviceurl);
        console.log('proxyname: %s', proxyname);

        callGenerate(metadataurlValue, serviceurl, proxyname);
    })
开发者ID:tschaumburg,项目名称:BreezeTypedefExtractor,代码行数:13,代码来源:app.ts


示例9: CliRebindReport

export default function CliRebindReport() {
    let pkg = require('../package.json');

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-w, --workspace <workspace>', 'The Power BI workspace Id')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-r, --report <reportId>', 'The Power BI report id')
        .option('-d, --dataset <datasetId>', 'The Power BI dataset id')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Description:');
        console.log('');
        console.log('    Rebinds a report with another dataset. Old dataset and new dataset should have the same schema.');
        console.log('');
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi rebind-report -c <collection> -w <workspace> -k <accessKey>');
    });

    program.parse(process.argv);

    let settings = config.merge(program);

    if (!(settings.collection && settings.workspace && settings.accessKey && settings.report && settings.dataset)) {
        program.help();
        return;
    }

    try {
        let credentials = new msrest.TokenCredentials(settings.accessKey, 'AppKey');
        let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

        let params: powerbi.RebindReportRequest = { datasetId: settings.dataset };

        client.reports.rebindReport(settings.collection, settings.workspace, settings.report, params, (err, result) => {
            if (err) {
                return cli.error(err);
            }

            cli.success('Rebind report has been completed successfully');
        });
    } catch (err) {
        cli.error(err);
    }
}
开发者ID:Microsoft,项目名称:PowerBI-Cli,代码行数:47,代码来源:cli-rebind-report.ts


示例10: CliDeleteDataset

export default function CliDeleteDataset() {
    let err;
    let program = require('commander');
    let colors = require('colors');
    let pkg = require('../package.json');
    let util = require('util');

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-w, --workspace <workspace>', 'The Power BI workspace')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-d, --dataset <dataset>', 'The dataset id')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi delete-dataset -c <collection> -w <workspace> -d <dataset> -k <accessKey>');
    });

    program.parse(process.argv);

    let settings = config.merge(program);

    if (!(settings.collection && settings.accessKey && settings.workspace)) {
        program.help();
    } else {
        try {
            let token = powerbi.PowerBIToken.createDevToken(settings.collection, settings.workspace);
            let credentials = new msrest.TokenCredentials(token.generate(settings.accessKey), 'AppToken');
            let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

            client.datasets.deleteDatasetById(settings.collection, settings.workspace, settings.dataset, (err, result) => {
                if (err) {
                    return cli.error(err);
                }

                cli.success('Dataset %s deleted successfully', settings.dataset);
            });
        } catch (err) {
            cli.error(err);
        }
    }
}
开发者ID:llenroc,项目名称:PowerBI-Cli,代码行数:44,代码来源:cli-delete-dataset.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript commander.name函数代码示例发布时间:2022-05-25
下一篇:
TypeScript commander.description函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap