| 39 | } |
| 40 | |
| 41 | async exec ([cmd, entity = '', user = '']) { |
| 42 | // Entities are in the format <scope>:<team> |
| 43 | // XXX: "description" option to libnpmteam is used as a description of the team, but in npm's options |
| 44 | // this is a boolean meaning "show the description in npm search output". |
| 45 | // Hence its being set to null here. |
| 46 | await otplease(this.npm, { ...this.npm.flatOptions }, opts => { |
| 47 | entity = entity.replace(/^@/, '') |
| 48 | switch (cmd) { |
| 49 | case 'create': return this.create(entity, opts) |
| 50 | case 'destroy': return this.destroy(entity, opts) |
| 51 | case 'add': return this.add(entity, user, opts) |
| 52 | case 'rm': return this.rm(entity, user, opts) |
| 53 | case 'ls': { |
| 54 | const match = entity.match(/[^:]+:.+/) |
| 55 | if (match) { |
| 56 | return this.listUsers(entity, opts) |
| 57 | } else { |
| 58 | return this.listTeams(entity, opts) |
| 59 | } |
| 60 | } |
| 61 | default: |
| 62 | throw this.usageError() |
| 63 | } |
| 64 | }) |
| 65 | } |
| 66 | |
| 67 | async create (entity, opts) { |
| 68 | await libteam.create(entity, opts) |