<commit_before>'use strict';

var Command = require('../lib/command');
var api = require('../lib/api');
var requireAuth = require('../lib/requireAuth');
var chalk = require('chalk');
var Table = require('cli-table');
var _ = require('lodash');
var logger = require('../lib/logger');

module.exports = new Command('list')
  .description('list the Firebases to which you have access')
  .before(requireAuth)
  .action(function(options) {
    return api.getProjects().then(function(projects) {
      var tableHead = ['Name', 'Project ID', 'Permissions', 'Instance'];
      var table = new Table({
        head: tableHead,
        style: {head: ['yellow']}
      });

      var out = [];
      _.forEach(projects, function(data, projectId) {
        var project = {
          name: data.name,
          id: projectId,
          permission: data.permission,
          instance: data.instances.database[0]
        };

        var displayPermission;
        switch (data.permission) {
        case 'own':
          displayPermission = chalk.cyan.bold('Owner');
          break;
        case 'edit':
          displayPermission = chalk.bold('Editor');
          break;
        case 'view':
        default:
          displayPermission = 'Viewer';
        }

        var displayName = data.name;
        if (options.project === data.id) {
          displayName = chalk.cyan.bold(displayName + ' (current)');
        }

        out.push(project);
        var row = [
          displayName,
          projectId,
          displayPermission,
          project.instance
        ];
        table.push(row);
      });

      logger.info(table.toString());
      return out;
    });
  });<commit_msg>Fixing current project selector in list<commit_after>'use strict';

var Command = require('../lib/command');
var api = require('../lib/api');
var requireAuth = require('../lib/requireAuth');
var chalk = require('chalk');
var Table = require('cli-table');
var _ = require('lodash');
var logger = require('../lib/logger');

module.exports = new Command('list')
  .description('list the Firebases to which you have access')
  .before(requireAuth)
  .action(function(options) {
    return api.getProjects().then(function(projects) {
      var tableHead = ['Name', 'Project ID', 'Permissions', 'Instance'];
      var table = new Table({
        head: tableHead,
        style: {head: ['yellow']}
      });

      var out = [];
      _.forEach(projects, function(data, projectId) {
        var project = {
          name: data.name,
          id: projectId,
          permission: data.permission,
          instance: data.instances.database[0]
        };

        var displayPermission;
        switch (data.permission) {
        case 'own':
          displayPermission = chalk.cyan.bold('Owner');
          break;
        case 'edit':
          displayPermission = chalk.bold('Editor');
          break;
        case 'view':
        default:
          displayPermission = 'Viewer';
        }

        var displayName = data.name;
        if (options.project === projectId) {
          displayName = chalk.cyan.bold(displayName + ' (current)');
        }

        out.push(project);
        var row = [
          displayName,
          projectId,
          displayPermission,
          project.instance
        ];
        table.push(row);
      });

      logger.info(table.toString());
      return out;
    });
  });
{'fraction_non_alphanumeric': 0.1434040047114252, 'fraction_numerical': 0.0005889281507656066, 'mean_word_length': 2.125114995400184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921207', 'n_tokens_mistral': 944, 'n_tokens_neox': 923, 'n_words': 219}