{"id":32160257,"url":"https://github.com/t-sasaki915/consoleask","last_synced_at":"2025-10-21T13:38:06.463Z","repository":{"id":300486174,"uuid":"1006165518","full_name":"t-sasaki915/ConsoleAsk","owner":"t-sasaki915","description":"Simple CLI user input library","archived":false,"fork":false,"pushed_at":"2025-07-08T12:16:54.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T13:56:01.307Z","etag":null,"topics":["haskell-library","stdin"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/ConsoleAsk","language":"Haskell","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/t-sasaki915.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2025-06-21T16:33:39.000Z","updated_at":"2025-07-08T12:16:58.000Z","dependencies_parsed_at":"2025-07-08T12:55:35.344Z","dependency_job_id":"3a70da30-1f0a-4195-9b2c-2611cc871d92","html_url":"https://github.com/t-sasaki915/ConsoleAsk","commit_stats":null,"previous_names":["t-sasaki915/consoleask"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/t-sasaki915/ConsoleAsk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-sasaki915%2FConsoleAsk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-sasaki915%2FConsoleAsk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-sasaki915%2FConsoleAsk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-sasaki915%2FConsoleAsk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t-sasaki915","download_url":"https://codeload.github.com/t-sasaki915/ConsoleAsk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-sasaki915%2FConsoleAsk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280271640,"owners_count":26302255,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["haskell-library","stdin"],"created_at":"2025-10-21T13:38:04.810Z","updated_at":"2025-10-21T13:38:06.458Z","avatar_url":"https://github.com/t-sasaki915.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConsoleAsk\nSimple CLI user input library\n\n## Example\n```haskell\nimport Data.Functor ((\u003c\u0026\u003e))\nimport Data.Text (Text)\nimport Text.Parsec (char, digit, many1)\nimport Text.Regex.TDFA ((=~))\n\nimport System.Console.Ask (Ask, ask, askOptional, askOrElse, runAsk, defaultBehaviour)\nimport System.Console.Ask.Askable (Askable (fromText), fromParsec)\n\ndata UserInformation = UserInformation\n    { name                   :: Text\n    , age                    :: Maybe Int\n    , birthday               :: Date\n    , notificationPreference :: NotificationPreference\n    } deriving Show\n\ndata NotificationPreference = NotificationPreference\n    { needNotifications :: Bool\n    , emailAddress      :: Maybe EmailAddress\n    } deriving Show\n\naskUserInformation :: Ask UserInformation\naskUserInformation =\n    UserInformation\n        \u003c$\u003e ask         \"What is your name?\"\n        \u003c*\u003e askOptional \"How old are you?\"\n        \u003c*\u003e ask         \"When is your birthday?\"\n        \u003c*\u003e askNotificationPreference\n\naskNotificationPreference :: Ask NotificationPreference\naskNotificationPreference = do\n    needNotifications' \u003c- askOrElse \"Do you need our update notifications?\" False\n\n    emailAddress' \u003c-\n        if needNotifications'\n            then Just \u003c$\u003e ask \"What is your email address?\"\n            else pure Nothing\n\n    pure NotificationPreference\n        { needNotifications = needNotifications'\n        , emailAddress      = emailAddress'\n        }\n\nnewtype EmailAddress = EmailAddress Text deriving Show\n\ninstance Askable EmailAddress where\n    fromText text =\n        if text =~ (\"[a-zA-Z0-9+._-]+@[a-zA-Z-]+\\\\.[a-z]+\" :: Text)\n            then Just (EmailAddress text)\n            else Nothing\n\ndata Date = Date Int Int deriving Show\n\ninstance Askable Date where\n    fromText = fromParsec $ do\n        day   \u003c- many1 digit \u003c\u0026\u003e read\n        _     \u003c- char '/'\n        month \u003c- many1 digit \u003c\u0026\u003e read\n\n        pure (Date day month)\n\nmain :: IO ()\nmain = do\n    userInfo \u003c- runAsk defaultBehaviour askUserInformation\n\n    print userInfo\n```\n```\nWhat is your name?\n\u003e Toma Sasaki\n\nHow old are you?\n\u003e\n\nWhen is your birthday?\n\u003e 15/9\n\nDo you need our update notifications? (Default: False)\n\u003e aye\n\nWhat is your email address?\n\u003e me@t-sasaki.net\n\nUserInformation\n    { name = \"Toma Sasaki\"\n    , age = Nothing\n    , birthday = Date 15 9\n    , notificationPreference =\n        NotificationPreference\n            { needNotifications = True\n            , emailAddress = Just (EmailAddress \"me@t-sasaki.net\")\n            }\n    }\n```\n\n## Features\n- Automatically parses input values to `Askable` instances. (See also: [Askable.hs](https://github.com/t-sasaki915/ConsoleAsk/blob/main/src/System/Console/Ask/Askable.hs))\n```haskell\nimport Control.Monad.IO.Class (liftIO)\nimport Data.Text (Text)\nimport qualified Data.Text as Text\nimport qualified Data.Text.IO as TextIO\n\nimport System.Console.Ask (Ask, ask, askOptional, askOrElse, defaultBehaviour, runAsk)\n\nmain :: IO ()\nmain = runAsk defaultBehaviour $ do\n    name              \u003c- ask         \"What is your name?\"               :: Ask Text\n    age               \u003c- askOptional \"How old are you?\"                 :: Ask (Maybe Int)\n    needNotifications \u003c- askOrElse   \"Do you need notifications?\" False :: Ask Bool\n\n    liftIO $ do\n        TextIO.putStrLn (\"Name: \" \u003c\u003e name)\n        TextIO.putStrLn (\"Age: \" \u003c\u003e Text.show age)\n        TextIO.putStrLn (\"Need notifications: \" \u003c\u003e Text.show needNotifications)\n```\n```\nWhat is your name?\n\u003e Toma Sasaki\n\nHow old are you?\n\u003e a\nInvalid input.\n\nHow old are you?\n\u003e 18\n\nDo you need notifications? (Default: False)\n\u003e no\n\nName: Toma Sasaki\nAge: 18\nNeed notifications: False\n```\n\n- `Askable` supports both `Text -\u003e Maybe a` and parsec.\n```haskell\nimport Data.Functor ((\u003c\u0026\u003e))\nimport Data.Text (Text)\nimport Text.Parsec (char, digit, many1)\nimport Text.Regex.TDFA ((=~))\n\nimport System.Console.Ask.Askable (Askable (fromText), fromParsec)\n\nnewtype EmailAddress = EmailAddress Text deriving Show\n\ninstance Askable EmailAddress where\n    fromText text =\n        if text =~ (\"[a-zA-Z0-9+._-]+@[a-zA-Z-]+\\\\.[a-z]+\" :: Text)\n            then Just (EmailAddress text)\n            else Nothing\n\ndata Date = Date Int Int deriving Show\n\ninstance Askable Date where\n    fromText = fromParsec $ do\n        day   \u003c- many1 digit \u003c\u0026\u003e read\n        _     \u003c- char '/'\n        month \u003c- many1 digit \u003c\u0026\u003e read\n\n        pure (Date day month)\n```\n\n- Custom prompt\n```haskell\nimport Control.Monad.IO.Class (liftIO)\nimport Data.Text (Text)\nimport qualified Data.Text as Text\nimport qualified Data.Text.IO as TextIO\n\nimport System.Console.Ask (Ask, ask', askOptional', askOrElse', defaultBehaviour, runAsk)\n\nmain :: IO ()\nmain = runAsk defaultBehaviour $ do\n    name              \u003c- ask'         \"What is your name?\"               \"Text\u003e \" :: Ask Text\n    age               \u003c- askOptional' \"How old are you?\"                 \"Int \u003e \" :: Ask (Maybe Int)\n    needNotifications \u003c- askOrElse'   \"Do you need notifications?\" False \"Y/N \u003e \" :: Ask Bool\n\n    liftIO $ do\n        TextIO.putStrLn (\"Name: \" \u003c\u003e name)\n        TextIO.putStrLn (\"Age: \" \u003c\u003e Text.show age)\n        TextIO.putStrLn (\"Need notifications: \" \u003c\u003e Text.show needNotifications)\n```\n```\nWhat is your name?\nText\u003e Toma Sasaki\n\nHow old are you?\nInt \u003e 18\n\nDo you need notifications? (Default: False)\nY/N \u003e True\n\nName: Toma Sasaki\nAge: 18\nNeed notifications: True\n```\n\n- Customisable behaviour (See also: [Behaviour.hs](https://github.com/t-sasaki915/ConsoleAsk/blob/main/src/System/Console/Ask/Behaviour.hs))\n```haskell\nimport Control.Monad.IO.Class (liftIO)\nimport Data.Text (Text)\nimport qualified Data.Text as Text\nimport qualified Data.Text.IO as TextIO\n\nimport System.Console.Ask (Ask, ask, askOptional, askOrElse, defaultBehaviour, runAsk, withBehaviour)\nimport System.Console.Ask.Behaviour (DefaultValueStyle (..), defaultValueStyle, invalidInputErrorMsg, set)\n\nmain :: IO ()\nmain = runAsk defaultBehaviour $ do\n    let customBehaviour1 = set invalidInputErrorMsg (Just \"??????\") defaultBehaviour\n        customBehaviour2 = set defaultValueStyle OnNewline defaultBehaviour\n\n    name              \u003c- ask \"What is your name?\" :: Ask Text\n    age               \u003c- withBehaviour customBehaviour1 (askOptional \"How old are you?\")                 :: Ask (Maybe Int)\n    needNotifications \u003c- withBehaviour customBehaviour2 (askOrElse   \"Do you need notifications?\" False) :: Ask Bool\n\n    liftIO $ do\n        TextIO.putStrLn (\"Name: \" \u003c\u003e name)\n        TextIO.putStrLn (\"Age: \" \u003c\u003e Text.show age)\n        TextIO.putStrLn (\"Need notifications: \" \u003c\u003e Text.show needNotifications)\n```\n```\nWhat is your name?\n\u003e Toma Sasaki\n\nHow old are you?\n\u003e a\n??????\n\nHow old are you?\n\u003e 18\n\nDo you need notifications?\nDefault: False\n\u003e True\n\nName: Toma Sasaki\nAge: 18\nNeed notifications: True\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-sasaki915%2Fconsoleask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft-sasaki915%2Fconsoleask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-sasaki915%2Fconsoleask/lists"}