{"id":27567474,"url":"https://github.com/nyaosorg/go-readline-ny","last_synced_at":"2025-10-14T22:24:53.806Z","repository":{"id":45234808,"uuid":"233245763","full_name":"nyaosorg/go-readline-ny","owner":"nyaosorg","description":"The New Yet another Readline for Go","archived":false,"fork":false,"pushed_at":"2025-06-25T19:41:36.000Z","size":597,"stargazers_count":29,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T13:02:18.209Z","etag":null,"topics":["command-line","go","golang","nyagos","readline","readline-library"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/nyaosorg/go-readline-ny","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/nyaosorg.png","metadata":{"files":{"readme":"README.md","changelog":"history.go","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":"2020-01-11T14:38:26.000Z","updated_at":"2025-06-25T19:41:39.000Z","dependencies_parsed_at":"2023-10-01T17:28:55.937Z","dependency_job_id":"753ba530-2ada-4b9c-bfcd-fcbb54df5db1","html_url":"https://github.com/nyaosorg/go-readline-ny","commit_stats":null,"previous_names":["zetamatta/go-readline-ny"],"tags_count":93,"template":false,"template_full_name":null,"purl":"pkg:github/nyaosorg/go-readline-ny","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-readline-ny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-readline-ny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-readline-ny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-readline-ny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nyaosorg","download_url":"https://codeload.github.com/nyaosorg/go-readline-ny/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-readline-ny/sbom","scorecard":{"id":699777,"data":{"date":"2025-08-11","repo":{"name":"github.com/nyaosorg/go-readline-ny","commit":"659522f2844afd6522ded69b7d2e15d341b28a0d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.9,"checks":[{"name":"Maintained","score":6,"reason":"8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/test.yml:4","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/nyaosorg/go-readline-ny/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/nyaosorg/go-readline-ny/test.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T04:55:46.115Z","repository_id":45234808,"created_at":"2025-08-22T04:55:46.116Z","updated_at":"2025-08-22T04:55:46.116Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021780,"owners_count":26087055,"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-14T02:00:06.444Z","response_time":60,"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":["command-line","go","golang","nyagos","readline","readline-library"],"created_at":"2025-04-20T20:01:50.817Z","updated_at":"2025-10-14T22:24:53.794Z","avatar_url":"https://github.com/nyaosorg.png","language":"Go","funding_links":[],"categories":["命令行","Command Line","Build Automation"],"sub_categories":["标准CLI","Standard CLI"],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/nyaosorg/go-readline-ny.svg)](https://pkg.go.dev/github.com/nyaosorg/go-readline-ny)\r\n[![Go Report Card](https://goreportcard.com/badge/github.com/nyaosorg/go-readline-ny)](https://goreportcard.com/report/github.com/nyaosorg/go-readline-ny)\r\n[![Wiki](https://img.shields.io/badge/Wiki-orange)](https://github.com/nyaosorg/go-readline-ny/wiki)\r\n[![License](https://img.shields.io/badge/License-MIT-red)](https://github.com/nyaosorg/go-readline-ny/blob/master/LICENSE)\r\n[![Go Test](https://github.com/nyaosorg/go-readline-ny/actions/workflows/test.yml/badge.svg)](https://github.com/nyaosorg/go-readline-ny/actions/workflows/test.yml)\r\n[![Awesome](https://awesome.re/badge.svg)](https://github.com/avelino/awesome-go)\r\n\r\nThe New Yet another Readline for Go (go-readline-ny)\r\n====================================================\r\n\r\n**go-readline-ny** is a one-line input library for CUI applications written in Go. It is designed to be extensible to meet diverse needs and has been used in the command-line shell [NYAGOS] for a long time.\r\n\r\n[NYAGOS]: https://github.com/nyaosorg/nyagos\r\n\r\n- Emacs-like key-bindings\r\n- Input history\r\n- Word completion (file names, command names, or any names in given array)\r\n- Syntax highlighting\r\n- Supported platforms: Windows and Linux\r\n- Full Unicode (UTF8) support, including:\r\n    - Surrogate-pair\r\n    - Emojis (via clipboard)\r\n    - Zero-width joiner (via clipboard)\r\n    - Variation selectors (via clipboard pasted with Ctrl-Y)\r\n- Add-Ons:\r\n    - [SKK] (Japanese input method editor)\r\n    - [Multi-lines Editing][go-multiline-ny]\r\n\r\n[SKK]: https://github.com/nyaosorg/go-readline-skk\r\n[go-multiline-ny]: https://github.com/hymkor/go-multiline-ny\r\n\r\n![Zero-Width-Joiner sample on Windows-Terminal](./emoji.png)\r\n\r\n![](./colorcmdline.png)\r\n\r\nexamples\r\n--------\r\n\r\n### [The most simple example](./examples/example1.go)\r\n\r\n```examples/example1.go\r\npackage main\r\n\r\nimport (\r\n    \"context\"\r\n    \"fmt\"\r\n\r\n    \"github.com/nyaosorg/go-readline-ny\"\r\n)\r\n\r\nfunc main() {\r\n    var editor readline.Editor\r\n    text, err := editor.ReadLine(context.Background())\r\n    if err != nil {\r\n        fmt.Printf(\"ERR=%s\\n\", err.Error())\r\n    } else {\r\n        fmt.Printf(\"TEXT=%s\\n\", text)\r\n    }\r\n}\r\n```\r\n\r\nIf the target platform includes Windows, you have to import and use [go-colorable](https://github.com/mattn/go-colorable) like example2.go .\r\n\r\n### [Tiny Shell](./examples/example2.go)\r\n\r\nThis is a sample demonstrating prompt change, syntax highlighting, filename completion, history browsing, and access to the operating system clipboard.\r\n\r\n```examples/example2.go\r\npackage main\r\n\r\nimport (\r\n    \"context\"\r\n    \"fmt\"\r\n    \"io\"\r\n    \"os\"\r\n    \"os/exec\"\r\n    \"regexp\"\r\n    \"strings\"\r\n\r\n    \"github.com/atotto/clipboard\"\r\n    \"github.com/mattn/go-colorable\"\r\n\r\n    \"github.com/nyaosorg/go-readline-ny\"\r\n    \"github.com/nyaosorg/go-readline-ny/completion\"\r\n    \"github.com/nyaosorg/go-readline-ny/keys\"\r\n    \"github.com/nyaosorg/go-readline-ny/simplehistory\"\r\n)\r\n\r\ntype OSClipboard struct{}\r\n\r\nfunc (OSClipboard) Read() (string, error) {\r\n    return clipboard.ReadAll()\r\n}\r\n\r\nfunc (OSClipboard) Write(s string) error {\r\n    return clipboard.WriteAll(s)\r\n}\r\n\r\nfunc main() {\r\n    history := simplehistory.New()\r\n\r\n    editor := \u0026readline.Editor{\r\n        PromptWriter: func(w io.Writer) (int, error) {\r\n            return io.WriteString(w, \"\\x1B[36;22m$ \") // print `$ ` with cyan\r\n        },\r\n        Writer:  colorable.NewColorableStdout(),\r\n        History: history,\r\n        Highlight: []readline.Highlight{\r\n            {Pattern: regexp.MustCompile(\"\u0026\"), Sequence: \"\\x1B[33;49;22m\"},\r\n            {Pattern: regexp.MustCompile(`\"[^\"]*\"`), Sequence: \"\\x1B[35;49;22m\"},\r\n            {Pattern: regexp.MustCompile(`%[^%]*%`), Sequence: \"\\x1B[36;49;1m\"},\r\n            {Pattern: regexp.MustCompile(\"\\u3000\"), Sequence: \"\\x1B[37;41;22m\"},\r\n        },\r\n        HistoryCycling: true,\r\n        PredictColor:   [...]string{\"\\x1B[3;22;34m\", \"\\x1B[23;39m\"},\r\n        ResetColor:     \"\\x1B[0m\",\r\n        DefaultColor:   \"\\x1B[33;49;1m\",\r\n\r\n        Clipboard: OSClipboard{},\r\n    }\r\n\r\n    editor.BindKey(keys.CtrlI, \u0026completion.CmdCompletionOrList2{\r\n        // Characters listed here are excluded from completion.\r\n        Delimiter: \"\u0026|\u003e\u003c;\",\r\n        // Enclose candidates with these characters when they contain spaces\r\n        Enclosure: `\"'`,\r\n        // String to append when only one candidate remains\r\n        Postfix: \" \",\r\n        // Function for listing candidates\r\n        Candidates: completion.PathComplete,\r\n    })\r\n    // If you do not want to list files with double-tab-key,\r\n    // use `CmdCompletion2` instead of `CmdCompletionOrList2`\r\n\r\n    fmt.Println(\"Tiny Shell. Type Ctrl-D to quit.\")\r\n    for {\r\n        text, err := editor.ReadLine(context.Background())\r\n\r\n        if err != nil {\r\n            fmt.Printf(\"ERR=%s\\n\", err.Error())\r\n            return\r\n        }\r\n\r\n        fields := strings.Fields(text)\r\n        if len(fields) \u003c= 0 {\r\n            continue\r\n        }\r\n        cmd := exec.Command(fields[0], fields[1:]...)\r\n        cmd.Stdout = os.Stdout\r\n        cmd.Stderr = os.Stderr\r\n        cmd.Stdin = os.Stdin\r\n\r\n        cmd.Run()\r\n\r\n        history.Add(text)\r\n    }\r\n}\r\n```\r\n\r\n### [Custom completion](examples/example3.go)\r\n\r\n```examples/example3.go\r\npackage main\r\n\r\nimport (\r\n    \"context\"\r\n    \"fmt\"\r\n    \"io\"\r\n    \"os\"\r\n\r\n    \"github.com/nyaosorg/go-readline-ny\"\r\n    \"github.com/nyaosorg/go-readline-ny/completion\"\r\n    \"github.com/nyaosorg/go-readline-ny/keys\"\r\n)\r\n\r\nfunc mains() error {\r\n    var editor readline.Editor\r\n\r\n    editor.PromptWriter = func(w io.Writer) (int, error) {\r\n        return io.WriteString(w, \"menu\u003e \")\r\n    }\r\n    candidates := []string{\"list\", \"say\", \"pewpew\", \"help\", \"exit\", \"Space Command\"}\r\n\r\n    // If you do not want to list files with double-tab-key,\r\n    // use `CmdCompletion2` instead of `CmdCompletionOrList2`\r\n\r\n    editor.BindKey(keys.CtrlI, \u0026completion.CmdCompletionOrList2{\r\n        // Characters listed here are excluded from completion.\r\n        Delimiter: \"\u0026|\u003e\u003c;\",\r\n        // Enclose candidates with these characters when they contain spaces\r\n        Enclosure: `\"'`,\r\n        // String to append when only one candidate remains\r\n        Postfix: \" \",\r\n        // Function for listing candidates\r\n        Candidates: func(field []string) (forComp []string, forList []string) {\r\n            if len(field) \u003c= 1 {\r\n                return candidates, candidates\r\n            }\r\n            return nil, nil\r\n        },\r\n    })\r\n    ctx := context.Background()\r\n    for {\r\n        line, err := editor.ReadLine(ctx)\r\n        if err != nil {\r\n            return err\r\n        }\r\n        fmt.Printf(\"TEXT=%#v\\n\", line)\r\n    }\r\n    return nil\r\n}\r\n\r\nfunc main() {\r\n    if err := mains(); err != nil {\r\n        fmt.Fprintln(os.Stderr, err)\r\n        os.Exit(1)\r\n    }\r\n}\r\n```\r\n\r\nRelease notes\r\n-------------\r\n\r\n- [Release notes (English)](release_note_en.md)\r\n- [Release notes (Japanese)](release_note_ja.md)\r\n\r\nLicense\r\n-------\r\n\r\nMIT License\r\n\r\nAcknowledgements\r\n----------------\r\n\r\n- [masamitsu-murase (Masamitsu MURASE)](https://github.com/masamitsu-murase) [#1]\r\n- [ram-on (Ramon)](https://github.com/ram-on) [#2]\r\n- [glejeune (Gregoire Lejeune)](https://github.com/glejeune) [#6]\r\n- [brammeleman](https://github.com/brammeleman) [#8]\r\n- [apstndb](https://github.com/apstndb) [#9]\r\n\r\n[#1]: https://github.com/nyaosorg/go-readline-ny/pull/1\r\n[#2]: https://github.com/nyaosorg/go-readline-ny/issues/2\r\n[#6]: https://github.com/nyaosorg/go-readline-ny/pull/6\r\n[#8]: https://github.com/nyaosorg/go-readline-ny/issues/8\r\n[#9]: https://github.com/nyaosorg/go-readline-ny/issues/9\r\n\r\nAuthor\r\n------\r\n\r\n- [hymkor (HAYAMA Kaoru)](https://github.com/hymkor)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyaosorg%2Fgo-readline-ny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnyaosorg%2Fgo-readline-ny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyaosorg%2Fgo-readline-ny/lists"}