| 116 | } |
| 117 | |
| 118 | async ls (org, user, opts) { |
| 119 | if (!org) { |
| 120 | throw new Error('First argument `orgname` is required.') |
| 121 | } |
| 122 | |
| 123 | let roster = await liborg.ls(org, opts) |
| 124 | if (user) { |
| 125 | const newRoster = {} |
| 126 | if (roster[user]) { |
| 127 | newRoster[user] = roster[user] |
| 128 | } |
| 129 | |
| 130 | roster = newRoster |
| 131 | } |
| 132 | if (opts.json) { |
| 133 | output.buffer(roster) |
| 134 | } else if (opts.parseable) { |
| 135 | output.standard(['user', 'role'].join('\t')) |
| 136 | Object.keys(roster).forEach(u => { |
| 137 | output.standard([u, roster[u]].join('\t')) |
| 138 | }) |
| 139 | } else if (!this.npm.silent) { |
| 140 | const chalk = this.npm.chalk |
| 141 | for (const u of Object.keys(roster).sort()) { |
| 142 | output.standard(`${u} - ${chalk.cyan(roster[u])}`) |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | module.exports = Org |