{"id":13410646,"url":"https://github.com/antham/strumt","last_synced_at":"2025-10-19T08:42:34.163Z","repository":{"id":37548324,"uuid":"94813478","full_name":"antham/strumt","owner":"antham","description":"Strumt is a library to create prompt chain","archived":false,"fork":false,"pushed_at":"2024-11-17T18:50:02.000Z","size":80,"stargazers_count":62,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T11:11:11.391Z","etag":null,"topics":["prompt","prompt-chain"],"latest_commit_sha":null,"homepage":"","language":"Go","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/antham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-06-19T19:33:16.000Z","updated_at":"2024-11-13T01:59:06.000Z","dependencies_parsed_at":"2024-01-08T14:30:53.251Z","dependency_job_id":"83e8f38f-cc58-483c-875c-34c2a0848ecb","html_url":"https://github.com/antham/strumt","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fstrumt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fstrumt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fstrumt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fstrumt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antham","download_url":"https://codeload.github.com/antham/strumt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485287,"owners_count":20946398,"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":["prompt","prompt-chain"],"created_at":"2024-07-30T20:01:08.177Z","updated_at":"2025-10-19T08:42:29.133Z","avatar_url":"https://github.com/antham.png","language":"Go","readme":"# Strumt [![codecov](https://codecov.io/gh/antham/strumt/branch/master/graph/badge.svg)](https://codecov.io/gh/antham/strumt) [![Go Report Card](https://goreportcard.com/badge/github.com/antham/strumt)](https://goreportcard.com/report/github.com/antham/strumt) [![GoDoc](https://godoc.org/github.com/antham/strumt?status.svg)](http://godoc.org/github.com/antham/strumt) [![GitHub tag](https://img.shields.io/github/tag/antham/strumt.svg)]()\n\nStrumt is a library to create prompt chain. It provides multiline prompt, input validation, retry on error, ability to create typesafe prompt, ability to customize prompt and error display, a recording of prompt session and the ability to easily test your prompt scenario.\n\n## Example\n\nCheckout godoc to have more examples : [https://godoc.org/github.com/antham/strumt](https://godoc.org/github.com/antham/strumt)\n\n---\n\n[![asciicast](https://asciinema.org/a/126121.png)](https://asciinema.org/a/126121)\n\n```go\npackage main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n    \"strconv\"\n\n    \"github.com/antham/strumt\"\n)\n\nfunc main() {\n    user := User{}\n\n    p := strumt.NewPromptsFromReaderAndWriter(bufio.NewReader(os.Stdin), os.Stdout)\n    p.AddLinePrompter(\u0026StringPrompt{\u0026user.FirstName, \"Enter your first name\", \"userName\", \"lastName\", \"userName\"})\n    p.AddLinePrompter(\u0026StringPrompt{\u0026user.LastName, \"Enter your last name\", \"lastName\", \"age\", \"lastName\"})\n    p.AddLinePrompter(\u0026IntPrompt{\u0026user.Age, \"Enter your age\", \"age\", \"\", \"age\"})\n    p.SetFirst(\"userName\")\n    p.Run()\n\n    for _, step := range p.Scenario() {\n        fmt.Println(step.PromptString())\n        fmt.Println(step.Inputs()[0])\n\n        if step.Error() != nil {\n            fmt.Println(step.Error())\n        }\n    }\n\n    fmt.Println()\n    fmt.Printf(\"User datas : %#v\", user)\n\n}\n\ntype StringPrompt struct {\n    store             *string\n    prompt            string\n    currentID         string\n    nextPrompt        string\n    nextPromptOnError string\n}\n\nfunc (s *StringPrompt) ID() string {\n\treturn s.currentID\n}\n\nfunc (s *StringPrompt) PromptString() string {\n    return s.prompt\n}\n\nfunc (s *StringPrompt) Parse(value string) error {\n    if value == \"\" {\n        return fmt.Errorf(\"Empty value given\")\n    }\n\n    *(s.store) = value\n\n    return nil\n}\n\nfunc (s *StringPrompt) NextOnSuccess(value string) string {\n    return s.nextPrompt\n}\n\nfunc (s *StringPrompt) NextOnError(err error) string {\n    return s.nextPromptOnError\n}\n\ntype IntPrompt struct {\n    store             *int\n    prompt            string\n    currentID         string\n    nextPrompt        string\n    nextPromptOnError string\n}\n\nfunc (i *IntPrompt) ID() string {\n\treturn i.currentID\n}\n\nfunc (i *IntPrompt) PromptString() string {\n    return i.prompt\n}\n\nfunc (i *IntPrompt) Parse(value string) error {\n    age, err := strconv.Atoi(value)\n\n    if err != nil {\n        return fmt.Errorf(\"%s is not a valid number\", value)\n    }\n\n    if age \u003c= 0 {\n        return fmt.Errorf(\"Give a valid age\")\n    }\n\n    *(i.store) = age\n\n    return nil\n}\n\nfunc (i *IntPrompt) NextOnSuccess(value string) string {\n    return i.nextPrompt\n}\n\nfunc (i *IntPrompt) NextOnError(err error) string {\n    return i.nextPromptOnError\n}\n\ntype User struct {\n    FirstName string\n    LastName  string\n    Age       int\n}\n```\n","funding_links":[],"categories":["Command Line","命令行","命令行工具### 标准 CLI`用于创建一个标准命令行应用程序的库`","Build Automation","命令行工具"],"sub_categories":["Standard CLI","标准CLI","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantham%2Fstrumt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantham%2Fstrumt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantham%2Fstrumt/lists"}