Exemplo n.º 1
0
function* searchConfig (context, heroku) {
    let search_key = new RegExp(context.args.key || context.flags.key, `i`),
        search = context.args.targets || context.flags.targets,
        apps = yield t1.App.find(search, heroku),
        results = [], result = {},
        execs = apps.map(app => co(function* () {
                let config = yield heroku.get(`/apps/${app.name}/config-vars`);
                _.forIn(config, (value, key) => {
                   if (search_key.test(key)) {
                       results.push({name: app.name, key: key, value: value});
                       _.set(result, `${app.name}.${key}`, value);
                   }
                });
            }));

    cli.debug(`  looking for variables in ${apps.length} apps ...`);
    yield execs;

    let fmt = (context.flags.format || ``).toLowerCase();
    if (fmt === `json`) {
        cli.log(JSON.stringify(result));
    } else {
        cli.log();
        cli.styledHeader(`Found Variables:\n`);
        cli.table(results, {
            columns: [
                {key: `name`}, {key: `key`}, {key: `value`}
            ]
        });
    }
}
Exemplo n.º 2
0
 .action(function () {
   cli.table(
       ['Lorem', 'Ipsum'],
       [
           ['Lorem ipsum dolor', 'sit amet est']
       ]
   );
 });
Exemplo n.º 3
0
exports.testTable = function(test) {
  test.expect(2);

  var log = [];
  cli.write = function(content) {
    log.push(content);
  };

  cli.run("testSimpleTable");
  test.equal(log[0], '+-------------------+--------------+\n| Lorem             | Ipsum        |\n+-------------------+--------------+\n| Lorem ipsum dolor | sit amet est |\n+-------------------+--------------+\n');

  
  cli.table(
      ['Lorem', 'Ipsum', 'dolor', 'sit', 1],
      [
          ['Lorem ipsum dolor', 'sit amet est', 1, 2, 3],
          ['Lorem ipsum dolor', 1, 2, 3, 'sit amet est']
      ]
  );
  test.equal(log[1], '+-------------------+--------------+-------+-----+--------------+\n| Lorem             | Ipsum        | dolor | sit | 1            |\n+-------------------+--------------+-------+-----+--------------+\n| Lorem ipsum dolor | sit amet est | 1     | 2   | 3            |\n| Lorem ipsum dolor | 1            | 2     | 3   | sit amet est |\n+-------------------+--------------+-------+-----+--------------+\n');

  test.done();
};