{"id":13465049,"url":"https://github.com/heapwolf/prompt-sync","last_synced_at":"2025-05-16T15:09:12.436Z","repository":{"id":18482052,"uuid":"21677471","full_name":"heapwolf/prompt-sync","owner":"heapwolf","description":"a synchronous prompt for node.js","archived":false,"fork":false,"pushed_at":"2023-10-20T13:55:17.000Z","size":39,"stargazers_count":220,"open_issues_count":26,"forks_count":42,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-12T14:17:11.714Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/heapwolf.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-10T03:11:03.000Z","updated_at":"2025-03-31T14:53:35.000Z","dependencies_parsed_at":"2024-06-18T12:31:21.110Z","dependency_job_id":"15015701-1f42-481c-9364-8fed71659438","html_url":"https://github.com/heapwolf/prompt-sync","commit_stats":{"total_commits":44,"total_committers":10,"mean_commits":4.4,"dds":0.5681818181818181,"last_synced_commit":"33a12524a6c829b7a1379939d866d903ab2e375e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fprompt-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fprompt-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fprompt-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fprompt-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heapwolf","download_url":"https://codeload.github.com/heapwolf/prompt-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553958,"owners_count":22090417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-31T14:00:56.146Z","updated_at":"2025-05-16T15:09:07.425Z","avatar_url":"https://github.com/heapwolf.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# SYNOPSIS\nA sync prompt for node. very simple. no C++ bindings and no bash scripts.\n\nWorks on Linux, OS X and Windows.\n\n# BASIC MODE\n```js\n\nvar prompt = require('prompt-sync')();\n//\n// get input from the user.\n//\nvar n = prompt('How many more times? ');\n```\n# WITH HISTORY\n\nHistory is an optional extra, to use simply install the history plugin. \n\n```sh\nnpm install --save prompt-sync-history\n```\n\n```js\nvar prompt = require('prompt-sync')({\n  history: require('prompt-sync-history')() //open history file\n});\n//get some user input\nvar input = prompt()\nprompt.history.save() //save history back to file\n```\n\nSee the [prompt-sync-history](http://npm.im/prompt-sync-history) module\nfor options, or fork it for customized behaviour. \n\n# API\n\n## `require('prompt-sync')(config) =\u003e prompt` \n\nReturns an instance of the `prompt` function.\nTakes `config` option with the following possible properties\n\n`sigint`: Default is `false`. A ^C may be pressed during the input process to abort the text entry. If sigint it `false`, prompt returns `null`. If sigint is `true` the ^C will be handled in the traditional way: as a SIGINT signal causing process to exit with code 130.\n\n`eot`: Default is `false`. A ^D pressed as the first character of an input line causes prompt-sync to echo `exit` and exit the process with code 0.\n\n`autocomplete`: A completer function that will be called when user enters TAB to allow for autocomplete. It takes a string as an argument an returns an array of strings that are possible matches for completion. An empty array is returned if there are no matches.\n\n`history`: Takes an object that supplies a \"history interface\", see [prompt-sync-history](http://npm.im/prompt-sync-history) for an example.\n\n## `prompt(ask, value, opts)`\n\n`ask` is the label of the prompt, `value` is the default value\nin absence of a response. \n\nThe `opts` argument can also be in the first or second parameter position.\n\nOpts can have the following properties\n\n`echo`: Default is `'*'`. If set the password will be masked with the specified character. For hidden input, set echo to `''` (or use `prompt.hide`).\n\n`autocomplete`: Overrides the instance `autocomplete` function to allow for custom \nautocompletion of a particular prompt.\n\n`value`: Same as the `value` parameter, the default value for the prompt. If `opts`\nis in the third position, this property will *not* overwrite the `value` parameter.\n\n`ask`: Sames as the `value` parameter. The prompt label. If `opts` is not in the first position, the `ask` parameter will *not* be overridden by this property.\n\n## `prompt.hide(ask)`\n\nConvenience method for creating a standard hidden password prompt, \nthis is the same as `prompt(ask, {echo: ''})`\n\n\n# LINE EDITING\nLine editing is enabled in the non-hidden mode. (use up/down arrows for history and backspace and left/right arrows for editing)\n\nHistory is not set when using hidden mode.\n\n# EXAMPLES\n\n```js\n  //basic:\n  console.log(require('prompt-sync')()('tell me something about yourself: '))\n\n  var prompt = require('prompt-sync')({\n    history: require('prompt-sync-history')(),\n    autocomplete: complete(['hello1234', 'he', 'hello', 'hello12', 'hello123456']),\n    sigint: false\n  });\n\n  var value = 'frank';\n  var name = prompt('enter name: ', value);\n  console.log('enter echo * password');\n  var pw = prompt({echo: '*'});\n  var pwb = prompt('enter hidden password (or don\\'t): ', {echo: '', value: '*pwb default*'})\n  var pwc = prompt.hide('enter another hidden password: ')\n  var autocompleteTest = prompt('custom autocomplete: ', {\n    autocomplete: complete(['bye1234', 'by', 'bye12', 'bye123456'])\n  });\n\n  prompt.history.save();\n\n  console.log('\\nName: %s\\nPassword *: %s\\nHidden password: %s\\nAnother Hidden password: %s', name, pw, pwb, pwc);\n  console.log('autocomplete2: ', autocompleteTest);\n\n  function complete(commands) {\n    return function (str) {\n      var i;\n      var ret = [];\n      for (i=0; i\u003c commands.length; i++) {\n        if (commands[i].indexOf(str) == 0)\n          ret.push(commands[i]);\n      }\n      return ret;\n    };\n  };\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fprompt-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheapwolf%2Fprompt-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fprompt-sync/lists"}