From 88ffdc51bf3277bcbb9c29d4d2b60f528dfc8716 Mon Sep 17 00:00:00 2001 From: Ole Bergen <54313166+olebergen@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:31:08 +0200 Subject: [PATCH 1/2] Make options optional --- src/question.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/question.ts b/src/question.ts index 4be6b5ec52..213166e2bf 100644 --- a/src/question.ts +++ b/src/question.ts @@ -14,7 +14,7 @@ import { createInterface } from 'node:readline' -export async function question(query: string, options: { choices: string[] }) { +export async function question(query: string, options?: { choices: string[] }) { let completer = undefined if (Array.isArray(options?.choices)) { completer = function completer(line: string) { From 2c505cb84db29b56e16750c13f7155351975def4 Mon Sep 17 00:00:00 2001 From: Ole Bergen <54313166+olebergen@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:31:08 +0200 Subject: [PATCH 2/2] Make options optional --- src/question.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/question.ts b/src/question.ts index 4be6b5ec52..7c56b4122e 100644 --- a/src/question.ts +++ b/src/question.ts @@ -14,11 +14,14 @@ import { createInterface } from 'node:readline' -export async function question(query: string, options: { choices: string[] }) { +export async function question( + query: string, + { choices }: { choices?: string[] } = {} +) { let completer = undefined - if (Array.isArray(options?.choices)) { + if (Array.isArray(choices)) { completer = function completer(line: string) { - const completions = options.choices + const completions = choices const hits = completions.filter((c) => c.startsWith(line)) return [hits.length ? hits : completions, line] }