{"id":13410549,"url":"https://github.com/peterh/liner","last_synced_at":"2025-05-14T05:10:37.265Z","repository":{"id":4297401,"uuid":"5428536","full_name":"peterh/liner","owner":"peterh","description":"Pure Go line editor with history, inspired by linenoise","archived":false,"fork":false,"pushed_at":"2023-06-23T14:09:49.000Z","size":242,"stargazers_count":1065,"open_issues_count":17,"forks_count":134,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-11T00:02:33.744Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Swarm-IITKgp/sandbox-git","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"COPYING","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":"2012-08-15T16:34:55.000Z","updated_at":"2025-04-07T07:50:51.000Z","dependencies_parsed_at":"2023-07-11T15:16:34.700Z","dependency_job_id":null,"html_url":"https://github.com/peterh/liner","commit_stats":{"total_commits":170,"total_committers":27,"mean_commits":6.296296296296297,"dds":0.6411764705882352,"last_synced_commit":"58a158787cd552b11ce4a45f589a5452072c1fc0"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterh%2Fliner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterh%2Fliner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterh%2Fliner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterh%2Fliner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterh","download_url":"https://codeload.github.com/peterh/liner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076849,"owners_count":22010611,"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-30T20:01:07.631Z","updated_at":"2025-05-14T05:10:37.232Z","avatar_url":"https://github.com/peterh.png","language":"Go","readme":"Liner\n=====\n\nLiner is a command line editor with history. It was inspired by linenoise;\neverything Unix-like is a VT100 (or is trying very hard to be). If your\nterminal is not pretending to be a VT100, change it. Liner also support\nWindows.\n\nLiner is intended for use by cross-platform applications. Therefore, the\ndecision was made to write it in pure Go, avoiding cgo, for ease of cross\ncompilation. Furthermore, features only supported on some platforms have\nbeen intentionally omitted. For example, Ctrl-Z is \"suspend\" on Unix, but\n\"EOF\" on Windows. In the interest of making an application behave the same\nway on every supported platform, Ctrl-Z is ignored by Liner.\n\nLiner is released under the X11 license (which is similar to the new BSD\nlicense).\n\nLine Editing\n------------\n\nThe following line editing commands are supported on platforms and terminals\nthat Liner supports:\n\nKeystroke    | Action\n---------    | ------\nCtrl-A, Home | Move cursor to beginning of line\nCtrl-E, End  | Move cursor to end of line\nCtrl-B, Left | Move cursor one character left\nCtrl-F, Right| Move cursor one character right\nCtrl-Left, Alt-B    | Move cursor to previous word\nCtrl-Right, Alt-F   | Move cursor to next word\nCtrl-D, Del  | (if line is *not* empty) Delete character under cursor\nCtrl-D       | (if line *is* empty) End of File - usually quits application\nCtrl-C       | Reset input (create new empty prompt)\nCtrl-L       | Clear screen (line is unmodified)\nCtrl-T       | Transpose previous character with current character\nCtrl-H, BackSpace | Delete character before cursor\nCtrl-W, Alt-BackSpace | Delete word leading up to cursor\nAlt-D        | Delete word following cursor\nCtrl-K       | Delete from cursor to end of line\nCtrl-U       | Delete from start of line to cursor\nCtrl-P, Up   | Previous match from history\nCtrl-N, Down | Next match from history\nCtrl-R       | Reverse Search history (Ctrl-S forward, Ctrl-G cancel)\nCtrl-Y       | Paste from Yank buffer (Alt-Y to paste next yank instead)\nTab          | Next completion\nShift-Tab    | (after Tab) Previous completion\n\nNote that \"Previous\" and \"Next match from history\" will retain the part of\nthe line that the user has already typed, similar to zsh's\n\"up-line-or-beginning-search\" (which is the default on some systems) or\nbash's \"history-search-backward\" (which is my preferred behaviour, but does\nnot appear to be the default `Up` keybinding on any system).\n\nGetting started\n-----------------\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/peterh/liner\"\n)\n\nvar (\n\thistory_fn = filepath.Join(os.TempDir(), \".liner_example_history\")\n\tnames      = []string{\"john\", \"james\", \"mary\", \"nancy\"}\n)\n\nfunc main() {\n\tline := liner.NewLiner()\n\tdefer line.Close()\n\n\tline.SetCtrlCAborts(true)\n\n\tline.SetCompleter(func(line string) (c []string) {\n\t\tfor _, n := range names {\n\t\t\tif strings.HasPrefix(n, strings.ToLower(line)) {\n\t\t\t\tc = append(c, n)\n\t\t\t}\n\t\t}\n\t\treturn\n\t})\n\n\tif f, err := os.Open(history_fn); err == nil {\n\t\tline.ReadHistory(f)\n\t\tf.Close()\n\t}\n\n\tif name, err := line.Prompt(\"What is your name? \"); err == nil {\n\t\tlog.Print(\"Got: \", name)\n\t\tline.AppendHistory(name)\n\t} else if err == liner.ErrPromptAborted {\n\t\tlog.Print(\"Aborted\")\n\t} else {\n\t\tlog.Print(\"Error reading line: \", err)\n\t}\n\n\tif f, err := os.Create(history_fn); err != nil {\n\t\tlog.Print(\"Error writing history file: \", err)\n\t} else {\n\t\tline.WriteHistory(f)\n\t\tf.Close()\n\t}\n}\n```\n\nFor documentation, see http://godoc.org/github.com/peterh/liner\n","funding_links":[],"categories":["Command Line","Misc","Go","命令行","\u003cspan id=\"命令行-command-line\"\u003e命令行 Command Line\u003c/span\u003e","Build Automation","命令行工具### 标准 CLI`用于创建一个标准命令行应用程序的库`","命令行工具"],"sub_categories":["Standard CLI","标准命令行交互","标准CLI","標準命令行交互","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterh%2Fliner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterh%2Fliner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterh%2Fliner/lists"}