{"id":13896397,"url":"https://github.com/giann/sirocco","last_synced_at":"2025-04-25T15:31:03.320Z","repository":{"id":54652603,"uuid":"170437026","full_name":"giann/sirocco","owner":"giann","description":"🦜 A collection of interactive command line prompts for Lua","archived":false,"fork":false,"pushed_at":"2020-03-31T12:58:04.000Z","size":624,"stargazers_count":109,"open_issues_count":3,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-03T23:32:51.136Z","etag":null,"topics":["cli","command-line","lua","prompt","terminal"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/giann.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":"2019-02-13T03:56:58.000Z","updated_at":"2025-03-22T04:19:35.000Z","dependencies_parsed_at":"2022-08-13T22:50:49.088Z","dependency_job_id":null,"html_url":"https://github.com/giann/sirocco","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Fsirocco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Fsirocco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Fsirocco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Fsirocco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giann","download_url":"https://codeload.github.com/giann/sirocco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250844244,"owners_count":21496531,"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":["cli","command-line","lua","prompt","terminal"],"created_at":"2024-08-06T18:02:53.382Z","updated_at":"2025-04-25T15:31:03.016Z","avatar_url":"https://github.com/giann.png","language":"Lua","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/logo.png\" alt=\"sirocco\" width=\"304\" height=\"304\"\u003e\n\u003c/p\u003e\n\n# Sirocco\nA collection of interactive command line prompts for Lua\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/example.gif\" alt=\"sirocco\"\u003e\n\u003c/p\u003e\n\n**Note:** Sirocco is in active development.\n\n## Installing\n\nRequirements:\n- Lua 5.1/JIT/5.2/5.3\n- luarocks \u003e= 3.0 (_Note: `hererocks -rlatest` will install 2.4, you need to specify it with `-r3.0`_)\n\n```bash\nluarocks install sirocco\n```\n\n## Quickstart\n\nSee [`example.lua`](https://github.com/giann/sirocco/blob/master/example.lua) for an exhaustive snippet of all sirocco's features.\n\n### Text prompt\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/prompt.png\" alt=\"Prompt\" width=\"218\"\u003e\n\u003c/p\u003e\n\nBasic text prompt. Every prompt inherits from it so most of its options apply to them.\n\n```lua\nPrompt {\n    -- The prompt\n    prompt         = \"A simple question\\n❱ \",\n    -- A placeholder that will dissappear once the user types something\n    placeholder    = \"A simple answer\",\n    -- Whether the answer is required or not\n    required       = true,\n    -- The default answer\n    default        = \"A default answer\",\n    -- When hitting `tab`, will try to autocomplete based on those values\n    possibleValues = {\n        \"some\",\n        \"possible\",\n        \"values\",\n    },\n    -- Must return whether the current text is valid + a message in case it's not\n    validator      = function(text)\n        return text:match(\"[a-zA-Z]*\"), \"Message when not valid\"\n    end,\n    -- If returns false, input will not appear at all\n    filter         = function(input)\n        return input:match(\"[a-zA-Z]*\")\n    end\n}:ask() -- Returns the answer\n```\n\n### Password\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/password.png\" alt=\"Password\" width=\"222\"\u003e\n\u003c/p\u003e\n\nObfuscates the input.\n\n```lua\nPassword {\n    prompt = \"Enter your secret (hidden answer)\\n❱ \",\n    -- When false *** are printed otherwise nothing\n    hidden = false\n}:ask() -- Returns the actual answer\n```\n\n### Confirm\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/confirm.png\" alt=\"Confirm\" width=\"266\"\u003e\n\u003c/p\u003e\n\nA simple yes/no prompt.\n\n```lua\nConfirm {\n    prompt = \"All finished?\"\n}:ask() -- Returns the answer\n```\n\n### List\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/list-single.png\" alt=\"Single Choice List\" width=\"252\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/list-multiple.png\" alt=\"Multiple Choices List\" width=\"284\"\u003e\n\u003c/p\u003e\n\nWill choose the appropriate list (check list or radio list).\n\n```lua\nList {\n    prompt   = \"Where are you from?\",\n    -- If true can select multiple choices (check list) otherwise one (radio list)\n    multiple = false,\n    -- List of choices\n    items    = {\n        {\n            -- The actual value returned if selected\n            value = \"New York\",\n            -- The value displayed to the user\n            label = \"New York\"\n        },\n        {\n            value = \"Paris\",\n            label = \"Paris\"\n        },\n        {\n            value = \"Rome\",\n            label = \"Rome\"\n        }\n    },\n    -- Indexes of already selected choices\n    default  = { 2, 4 },\n}:ask() -- Returns a table of the selected choices\n```\n\n### Composite\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/giann/sirocco/raw/master/assets/composite.png\" alt=\"Composite\" width=\"418\"\u003e\n\u003c/p\u003e\n\nWill jump from field to field when appropriate.\n\n**TODO:** field's length should be optional\n\n```lua\nComposite {\n    prompt = \"What's your birthday? \",\n    -- Separator between each fields\n    separator = \" / \",\n    -- Fields definition\n    fields = {\n        {\n            placeholder = \"YYYY\",\n            filter = function(input)\n                return input:match(\"%d\")\n                    and input\n                    or \"\"\n            end,\n            -- Required\n            length = 4,\n        },\n        {\n            placeholder = \"mm\",\n            filter = function(input)\n                return input:match(\"%d\")\n                    and input\n                    or \"\"\n            end,\n            length = 2,\n        },\n        {\n            placeholder = \"dd\",\n            filter = function(input)\n                return input:match(\"%d\")\n                    and input\n                    or \"\"\n            end,\n            length = 2,\n        },\n    }\n}:ask() -- Returns a table of each field's answer\n```","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiann%2Fsirocco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiann%2Fsirocco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiann%2Fsirocco/lists"}