Skip to content

Commit

Permalink
Make options optional (#437)
Browse files Browse the repository at this point in the history
* Make options optional

* Make options optional
  • Loading branch information
olebergen committed Jun 13, 2022
1 parent c488737 commit 113f6e8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/question.ts
Expand Up @@ -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]
}
Expand Down

0 comments on commit 113f6e8

Please sign in to comment.