-
Notifications
You must be signed in to change notification settings - Fork 224
/
rename.ts
26 lines (23 loc) · 906 Bytes
/
rename.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import color from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import heredoc from 'tsheredoc'
export default class Rename extends Command {
static topic = 'spaces';
static description = 'renames a space';
static example = heredoc(`
$ heroku spaces:rename --from old-space-name --to new-space-name
Renaming space old-space-name to new-space-name... done
`)
static flags = {
from: flags.string({required: true, description: 'current name of space'}),
to: flags.string({required: true, description: 'desired name of space'}),
};
public async run(): Promise<void> {
const {flags} = await this.parse(Rename)
const {to, from} = flags
ux.action.start(`Renaming space from ${color.cyan(from)} to ${color.green(to)}`)
await this.heroku.patch(`/spaces/${from}`, {body: {name: to}})
ux.action.stop()
}
}