M src/cmds/league_cmds/archive.js => src/cmds/league_cmds/archive.js +2 -6
@@ 2,6 2,7 @@ import CFonts from 'cfonts'
import inquirer from 'inquirer'
import { DB } from 'mymigrate'
import { archivableLeagues } from '../../leagues'
+import { confirmQuestion } from '../../questions'
import exec from '../../handlers/league_cmds/archive'
export const command = 'archive'
@@ 22,12 23,7 @@ function leagueSelectionQuestion (conn) {
},
pageSize: 10,
},
- {
- type: 'confirm',
- name: 'confirm',
- message: 'Archive this league?',
- default: true,
- },
+ confirmQuestion ('Archive this league?'),
])
}
}
M src/cmds/league_cmds/new.js => src/cmds/league_cmds/new.js +9 -9
@@ 3,6 3,7 @@ import inquirer from 'inquirer'
import { DB } from 'mymigrate'
import { Constants, TeamName } from '../../constants'
import { teamsByKind, randomTeam } from '../../team_names'
+import { confirmQuestion } from '../../questions'
import exec from '../../handlers/league_cmds/new'
export const command = 'new'
@@ 111,17 112,16 @@ function teamSelectionQuestion (conn, index) {
function confirmationQuestion (pres) {
return inquirer.prompt ([
- {
- type: 'confirm',
- name: 'confirm',
- message: 'Create this league?',
- default: true,
- when (res) {
+ Object.assign (
+ confirmQuestion ('Create this league?'),
+ {
+ when (res) {
// used as a hack to collect previous results in new one
- Object.assign (res, pres)
- return true
+ Object.assign (res, pres)
+ return true
+ },
},
- },
+ ),
])
}
M src/cmds/league_cmds/remove.js => src/cmds/league_cmds/remove.js +2 -6
@@ 2,6 2,7 @@ import CFonts from 'cfonts'
import inquirer from 'inquirer'
import { DB } from 'mymigrate'
import { removableLeagues } from '../../leagues'
+import { confirmQuestion } from '../../questions'
import exec from '../../handlers/league_cmds/remove'
export const command = ['remove', 'rm']
@@ 22,12 23,7 @@ function leagueSelectionQuestion (conn) {
},
pageSize: 10,
},
- {
- type: 'confirm',
- name: 'confirm',
- message: 'Remove this league?',
- default: true,
- },
+ confirmQuestion ('Remove this league?'),
])
}
}
M src/cmds/season_cmds/new.js => src/cmds/season_cmds/new.js +2 -6
@@ 3,6 3,7 @@ import inquirer from 'inquirer'
import { DB } from 'mymigrate'
import { leaguesForNewSeason } from '../../leagues'
import { nextSeasonForLeague } from '../../seasons'
+import { confirmQuestion } from '../../questions'
import { Constants } from '../../constants'
import exec from '../../handlers/season_cmds/new'
@@ 48,12 49,7 @@ function questions (conn, { league = '' }) {
return true
},
},
- {
- type: 'confirm',
- name: 'confirm',
- message: 'Create this season?',
- default: true,
- },
+ confirmQuestion ('Create this season?'),
])
}
}
A src/questions.js => src/questions.js +8 -0
@@ 0,0 1,8 @@
+export function confirmQuestion (msg) {
+ return {
+ type: 'confirm',
+ name: 'confirm',
+ message: msg,
+ default: true,
+ }
+}