本文整理汇总了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();
}
}
示例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()
}
示例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 => {
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
})
示例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);
}
}
示例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);
}
}
}