{"id":32118893,"url":"https://github.com/ocpu/question-deno","last_synced_at":"2026-02-18T22:01:04.725Z","repository":{"id":43756828,"uuid":"362972908","full_name":"ocpu/question-deno","owner":"ocpu","description":"A module for deno to make interactive prompts in the terminal","archived":false,"fork":false,"pushed_at":"2024-06-01T04:18:22.000Z","size":140,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-15T20:53:27.230Z","etag":null,"topics":["cli","deno","interactive","module","prompt","stdin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ocpu.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-29T23:28:52.000Z","updated_at":"2023-01-20T13:30:05.000Z","dependencies_parsed_at":"2022-08-21T19:50:07.189Z","dependency_job_id":null,"html_url":"https://github.com/ocpu/question-deno","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ocpu/question-deno","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocpu%2Fquestion-deno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocpu%2Fquestion-deno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocpu%2Fquestion-deno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocpu%2Fquestion-deno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocpu","download_url":"https://codeload.github.com/ocpu/question-deno/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocpu%2Fquestion-deno/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","deno","interactive","module","prompt","stdin"],"created_at":"2025-10-20T17:46:00.116Z","updated_at":"2026-02-18T22:01:04.717Z","avatar_url":"https://github.com/ocpu.png","language":"TypeScript","readme":"# Question\n\nThis is a module that can handle CLI questions/inquiries that can be resolved in a CLI. This module requires the use of `--unstable` flag since the raw reader API is not finalized yet.\n\n```typescript\nimport question from 'https://raw.githubusercontent.com/ocpu/question-deno/master/mod.ts'\n\nconst result = await question('confirm', 'Confirm removal of X?', true)\nif (result === undefined) console.log('Prompt was canceled')\nelse if (result) console.log('I will now remove X')\nelse console.log('X will not be removed')\n```\n\nEach input type is documented in the overload list for the question function, it describes the use, the parameters, and controls.\n\nTest the different question types: `deno run --unstable https://raw.githubusercontent.com/ocpu/question-deno/master/demo.ts`\n\n\u003cdetails\u003e\n\u003csummary\u003eTOC\u003c/summary\u003e\n\n- [Question](#question)\n  - [Question Types](#question-types)\n    - [Input](#input)\n    - [Confirm](#confirm)\n    - [List](#list)\n    - [Checkbox](#checkbox)\n    - [Password](#password)\n  - [Config](#config)\n    - [Config option `keypressReader`](#config-option-keypressreader)\n    - [Config option `writer`](#config-option-writer)\n\n\u003c/details\u003e\n\n## Question Types\n\nCurrent question types:\n\n- [`input`](#input): Ask the user for a free form text answer.\n- [`confirm`](#confirm): Ask for a confirmation about an action.\n- [`list`](#list): Provide a list from which the user can chose one option.\n- [`checkbox`](#checkbox): Provide a list of options from which the user can mark the options they want.\n- [`password`](#password): Provide a free form password input with substitution text.\n\n### Input\n\nCreate a generic text input question requesting the user to input text in a free form format.\nA default value can be provided and if the free form text input is blank that value will be\nused instead.\n\nControls:\n\n- `Ctrl+c` will have the question canceled and return `undefined`.\n- `Ctrl+d` will exit the whole script no questions asked with a `Deno.exit()`.\n- `Up` arrow or `Home` key will move the cursor to the start of the prompt text.\n- `Down` arrow or `End` key will move the cursor to the end of the prompt text.\n- `Left` arrow will move the cursor one step to the left once if able.\n- `Right` arrow will move the cursor one step to the right once if able.\n- `Enter` will return the test inputted or the provided default value.\n\n### Confirm\n\nCreate a confirmation question that resolves to a true or false based on user input. It\ntakes an `undefined`, `true`, or `false` value as the default value. Each of the default\nvalue types has an effect on how the prompt looks like.\n\n- `undefined` will suffix the prompt with `[y/n]`\n- `true` will suffix the prompt with `[Y/n]`\n- `false` will suffix the prompt with `[y/N]`\n\nThe only valid values are anything starting with y or n uppercase or lowercase. The y and\nn is derived from the positive and negative labels. You can customize the labels in the\noptions object The prompt can be canceled and will then return `undefined`.\n\nControls:\n\n- `Ctrl+c` will have the question canceled and return `undefined`.\n- `Ctrl+d` will exit the whole script no questions asked with a `Deno.exit()`.\n- `Up` arrow or `Home` key will move the cursor to the start of the prompt text.\n- `Down` arrow or `End` key will move the cursor to the end of the prompt text.\n- `Left` arrow will move the cursor one step to the left once if able.\n- `Right` arrow will move the cursor one step to the right once if able.\n- `Enter` will return the parsed result of the text.\n\n### List\n\nCreates a list of selectable items from which one item can be chosen. If no items are available\nto be selected this will return `undefined` without a question prompt.\n\nControls:\n\n- `Ctrl+c` will have the question canceled and return `undefined`.\n- `Ctrl+d` will exit the whole script no questions asked with a `Deno.exit()`.\n- `Up` arrow will move the selected item up once if able.\n- `Down` arrow will move the selected item down once if able.\n- `Home` will move the selected item up to the start if able.\n- `End` will move the selected item down to the end if able.\n- `PageUp` will move the selected item up by the actual list window size if able.\n- `PageDown` will move the selected item down by the actual list window size if able.\n- `Enter` will return the currently selected item.\n\nThe options can either be a list of strings or an object describing the different options.\n\nThis control supports filtering by the label set by the option. To get started with the default configuration set the `filtering` list option to true. It will try to match the characters input with the label values.\n\nThe filtering has support to be able to search by exact label value, highlight the sections on the label that is matching the string, only sort the options by the string instead to removing the non matching options, and sort the options by specificity rank or the specified manual sorting.\n\n```typescript\nimport question from 'https://raw.githubusercontent.com/ocpu/question-deno/master/mod.ts'\n\nawait question('list', 'Select groceries?', ['Cheese', 'Milk', 'Tofu'])\nawait question('list', 'Select groceries?', {\n  // \u003cLabel\u003e: \u003cvalue\u003e - value can be anything\n  'Cheese': 'cheese',\n  'Milk': 'milk',\n  'Tofu': 'tofu',\n})\n```\n\n### Checkbox\n\nCreates a list of selectable items from which one item will be chosen. If no items are available\nto be selected this will return `undefined` without a question prompt.\n\nControls:\n\n\n- `Ctrl+c` will have the question canceled and return `undefined`.\n- `Ctrl+d` will exit the whole script no questions asked with a `Deno.exit()`.\n- `Ctrl+a` will select/deselect all options.\n- `Up` arrow will move the selected item up once if able.\n- `Down` arrow will move the selected item down once if able.\n- `Home` will move the selected item up to the start if able.\n- `End` will move the selected item down to the end if able.\n- `PageUp` will move the selected item up by the actual list window size if able.\n- `PageDown` will move the selected item down by the actual list window size if able.\n- `Space` will mark/unmark the selected item.\n- `Enter` will return all marked items in a list.\n\nThe options can either be a list of strings or an object describing the different options.\n\nIf the options parameter is a plain object where the key is the label and the value is a\nobject definition how the option is represented in the list and with a value. The representation\nkeys are:\n\n- `dependencies`: This is a value that takes a index, label, or a list of indices and labels to\n  express the reliance of a different option. So whenever any dependant option is select this one is too. Same for deselects.\n- `selected`: This makes the option selected by default. If the option depends on any other options\n  They will also be selected.\n\nThis control supports filtering by the label set by the option. To get started with the default configuration set the `filtering` checkbox option to true. It will try to match the characters input with the label values.\n\nThe filtering has support to be able to search by exact label value, highlight the sections on the label that is matching the string, only sort the options by the string instead to removing the non matching options, and sort the options by specificity rank or the specified manual sorting.\n\n```typescript\nimport question from 'https://raw.githubusercontent.com/ocpu/question-deno/master/mod.ts'\n\nawait question('checkbox', 'Select toppings?', ['Cheese', 'Garlic', 'Salami'])\nawait question('checkbox', 'Select toppings?', {\n  // \u003cLabel\u003e: \u003cOptions\u003e - value can be anything\n  'Cheese': { value: 'cheese', selected: true },\n  'Garlic': { value: 'garlic' },\n  'Salami': { value: 'salami' },\n})\n```\n\n### Password\n\nCreates a free form text input that does not print the characters normally printed by the `input`\nprompt. The characters are substituted for a substitute string you can provide. If the substitute\nparameter is a boolean false no substitute characters will be printed.\n\nThe substitute string if longer than 1 character can be called a pattern and will also be printed\nin that pattern. So if you have a pattern of `\u003c\u003e` and that length of the text i 5 the substitution\nwill look like `\u003c\u003e\u003c\u003e\u003c`.\n\nControls:\n\n- `Ctrl+c` will have the question canceled and return `undefined`.\n- `Ctrl+d` will exit the whole script no questions asked with a `Deno.exit()`.\n- `Up` arrow or `Home` key will move the cursor to the start of the prompt text.\n- `Down` arrow or `End` key will move the cursor to the end of the prompt text.\n- `Left` arrow will move the cursor one step to the left once if able.\n- `Right` arrow will move the cursor one step to the right once if able.\n- `Enter` will return the test inputted or the provided default value.\n\n## Config\n\nThe project currently supports these configuration options:\n- [`keypressReader`](#config-option-keypressreader): A way of specifying from where the input characters will be read from. Default is `Deno.stdin`.\n- [`writer`](#config-option-writer): A way of specifying from where to output the option rendering. Default is `Deno.stdout`.\n\nThese options mostly come in handy when you want use the program you are writing as a start, end, and/or in between step of linux pipes.\n\n### Config option `keypressReader`\n\nYou can config keypress reader to prevent [\"Keypress can be read only under TTY\" error if you try to use piped input](https://github.com/ocpu/question-deno/issues/1) on Linux:\n\n```typescript\nimport question, { questionConfig as questionConfig } from 'https://raw.githubusercontent.com/ocpu/question-deno/master/mod.ts'\n\ntry {\n  // requires --allow-read on the file specified.\n  const tty = await Deno.open(\"/dev/tty\");\n  if (Deno.isatty(tty.rid)) {\n    questionConfig.keypressReader = tty;\n  }\n} catch(e) {}\n```\n\n### Config option `writer`\n\nThis config option lets you direct the output flow of the prompts supported by the library. It is most useful when you want your program to output something for a different program in a pipe chain.\n\n```typescript\nimport question, { questionConfig as questionConfig } from 'https://raw.githubusercontent.com/ocpu/question-deno/master/mod.ts'\n\ntry {\n  // requires --allow-write on the file specified.\n  const tty = await Deno.open(\"/dev/tty\", { write: true });\n  if (Deno.isatty(tty.rid)) {\n    questionConfig.writer = tty;\n  }\n} catch(e) {}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focpu%2Fquestion-deno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focpu%2Fquestion-deno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focpu%2Fquestion-deno/lists"}