Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 94 lines (77 sloc) 2.54 KB
#!/usr/bin/env node
var Chalk = require('chalk');
var Cli = require('structured-cli');
var Package = require('../package.json');
var Updates = require('update-notifier');
var _ = require('lodash');
var notifier = Updates({
pkg: {
name: Package.name,
version: Package.version,
},
});
notifier.notify();
var cli = Cli.createApp({
description: 'Auth0 Command Line Interface',
version: Package.version
});
cli.addChild(require('./auth0_scaffold'));
cli.addChild(require('./auth0_create'));
cli.addChild(require('./auth0_ls'));
cli.addChild(require('./auth0_toggle')('enable'));
cli.addChild(require('./auth0_toggle')('disable'));
cli.addChild(require('./edit'));
cli.addChild(require('./rm'));
cli.addChild(require('./logs'));
Cli.run(cli)
.timeout(1000 * 60 * 30, Cli.error.timeout('Command timed out after 30 min'))
// Code: 1
.catch(_.matchesProperty('code', 'E_CANCELLED'), function (err) {
console.error(err.message);
process.exit(1);
})
// Code: 2
.catch(_.matchesProperty('code', 'E_INVALID'), function (err) {
console.error(err.parser.formatUsage());
console.error(Chalk.red(err.message));
process.exit(2);
})
// Code: 3
.catch(_.matchesProperty('code', 'E_HINT'), function (err) {
console.error(err.message);
process.exit(3);
})
// Code: 4
.catch(_.matchesProperty('code', 'E_TIMEOUT'), function (err) {
console.error(Chalk.red(err.message));
process.exit(4);
})
// Code: 5
.catch(_.matchesProperty('code', 'E_NOTFOUND'), function (err) {
console.error(Chalk.red(err.message));
process.exit(5);
})
// Code: 6
.catch(_.matchesProperty('code', 'E_BADREQUEST'), function (err) {
console.error(Chalk.red(err.message));
process.exit(6);
})
// Code: 7
.catch(_.matchesProperty('code', 'E_SERVERERROR'), function (err) {
console.error(Chalk.red(err.message));
process.exit(7);
})
// Code: 8
.catch(_.matchesProperty('code', 'E_NOTAUTHORIZED'), function (err) {
console.error(Chalk.red(err.message));
process.exit(8);
}) // Code: 99
.catch(function (err) {
console.error(Chalk.red('Uncaught error: ', err.message));
console.error(err.stack);
console.error('Please report this at: https://github.com/auth0/wt-cli/issues');
process.exit(99);
})
.then(function () {
process.exit(0);
});