-
Notifications
You must be signed in to change notification settings - Fork 1
/
status.ts
51 lines (43 loc) · 1.49 KB
/
status.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { flags } from '@oclif/command'
import { Codex } from '../services/codex'
import ui from '../services/ui'
import chalk from 'chalk'
import BaseCommand from '../base/base-command'
import state, { Mode, Status as StateStatus } from '../services/state'
export default class Status extends BaseCommand {
static description = 'display status information'
static examples = [ '$ codex status' ]
static flags = {
...BaseCommand.flags,
reset: flags.boolean({char: 'r', default: false})
}
async run() {
const codex = new Codex()
await codex.load()
switch (state.mode) {
case Mode.EDIT: {
if (state.status === StateStatus.PATCH_FAILED) {
ui.info(`editing ${chalk.redBright('FAILED')} patch number ${chalk.redBright(state.data.patch)} in file ${chalk.yellowBright(state.data.file)}`)
} else {
ui.info(`editing patch number ${chalk.yellowBright(state.data.patch)} in file ${chalk.yellowBright(state.data.file)}`)
}
if (this.flags.reset) {
const { Toggle } = require('enquirer')
const prompt = new Toggle({
message: 'Are you sure you want to reset the internal state to idle?',
enabled: 'Yes',
disabled: 'No'
})
if (await prompt.run()) {
ui.info('setting internal state to idle')
state.setIdle().save()
}
}
break
}
default: {
ui.info('up to date; nothing to commit')
}
}
}
}