Skip to content

Commit c6e69f8

Browse files
committed
update init questions to support new commander
1 parent dba199d commit c6e69f8

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/cli/initialize.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { authTokenQuestion } from './auth.js';
1919
/**
2020
* inquirer.js question which makes the user confirm the initialize operation.
2121
*/
22-
const confirmInitializeQuestion = {
22+
const confirmQuestion = {
2323
type: 'confirm',
2424
name: 'confirmed',
2525
message: festiveStyle(
@@ -29,22 +29,18 @@ const confirmInitializeQuestion = {
2929
prefix: festiveEmoji(),
3030
};
3131

32-
/**
33-
* Array of inquirer questions which will be asked in order.
34-
* The answers will provide us all of the information we need to initialize.
35-
*/
36-
const initializeQuestions = [
37-
{
32+
const initializeQuestions = {
33+
year: {
3834
// in future if list of years becomes too large the change to raw input.
39-
type: 'list',
40-
name: 'year',
35+
type: 'select',
4136
message: festiveStyle('What year of advent of code are you doing?'),
42-
prefix: festiveEmoji(),
43-
choices: [...getConfigValue('aoc.validation.years')].reverse(),
37+
choices: [...getConfigValue('aoc.validation.years')]
38+
.reverse()
39+
.map((year) => ({ value: year })),
4440
loop: false,
4541
},
46-
authTokenQuestion,
47-
];
42+
authToken: authTokenQuestion,
43+
};
4844

4945
/**
5046
* A Link which creates all required files in the cwd.
@@ -67,15 +63,12 @@ const createFiles = async ({ answers }) => {
6763
*/
6864
export const initializeAction = async () => {
6965
// if there are files in the cwd, get confirmation with the user that they want to proceed.
70-
if (
71-
!(await cwdIsEmpty()) &&
72-
!(await assertUserConfirmation(confirmInitializeQuestion)())
73-
) {
66+
if (!(await cwdIsEmpty()) && !(await assertUserConfirmation({ confirmQuestion }))) {
7467
return;
7568
}
7669

7770
// get all the info we need in order to initialize.
78-
const { answers } = await getAnswersFromUser(initializeQuestions)();
71+
const answers = await getAnswersFromUser({ questions: initializeQuestions });
7972

8073
// run initialize steps in an action chain that reports its progress to the user.
8174
const actionChain = createChainWithProgress(

0 commit comments

Comments
 (0)