UNPKG

861 BJavaScriptView Raw
1var Table = require('cli-table');
2var _ = require('lodash');
3var chalk = require('chalk');
4
5// Register a new profile in the 4front global config file
6module.exports = function(program, done) {
7 // If the user is a member of more than 1 org, make them select which one
8 // to display apps for.
9
10 var profiles = program.globalConfig.profiles;
11 if (_.isArray(profiles) === false || profiles.length === 0) {
12 return console.log("No profiles configured. Add one by running '4front add-profile'");
13 }
14
15 // Display the apps in a grid.
16 var table = new Table({
17 head: [chalk.cyan('name'), chalk.cyan('endpoint'), chalk.cyan('default')],
18 colWidths: [25, 35, 10]
19 });
20
21 _.each(profiles, function(profile) {
22 table.push([profile.name || '', profile.endpoint, profile.default ? 'true' : 'false'])
23 });
24
25 console.log(table.toString());
26 done();
27};