File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,11 @@ exports.randomInteractive = {
5252 symbol : '>' ,
5353 menu : [ ]
5454}
55+
56+ exports . randomAgain = {
57+ type : 'confirm' ,
58+ query : bold ( ) . blue ( ' - Would you like to try another random?' ) ,
59+ handle : 'redo' ,
60+ accept : 'y' ,
61+ deny : 'n'
62+ }
Original file line number Diff line number Diff line change @@ -160,6 +160,21 @@ async function _searchAgain() {
160160 }
161161}
162162
163+ /**
164+ * Check if the user wants to make another research
165+ */
166+ async function _randomAgain ( ) {
167+ const input = await qoa . confirm ( prompt . randomAgain )
168+ if ( input . redo ) {
169+ process . stdout . write ( '\u001Bc' ) // Clear the console
170+ displayRandomArticlesList ( )
171+ }
172+
173+ if ( ! input . redo ) {
174+ process . exit ( 1 )
175+ }
176+ }
177+
163178/**
164179 * Bootstrap the app
165180 */
@@ -222,7 +237,8 @@ const displayRandomArticlesList = async () => {
222237 await _checkUserAnswers ( input , lang )
223238 const response = await fetch . getArticle ( input . userPick , lang )
224239 _displayArticle ( response )
225- prompt . historyInteractive . menu = [ ]
240+ prompt . randomInteractive . menu = [ ]
241+ _randomAgain ( )
226242}
227243
228244exports . displayRandomArticlesList = displayRandomArticlesList
You can’t perform that action at this time.
0 commit comments