-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/term: add history APIs. #15
base: master
Are you sure you want to change the base?
Conversation
…ary can save and restore the history
This PR (HEAD: 1ca6c26) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/term/+/603957. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
Message from Ian Lance Taylor: Patch Set 5: Commit-Queue+1 Hold+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
Message from Go LUCI: Patch Set 5: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2024-08-08T19:42:10Z","revision":"e160a998f431e39e998b65000039efedfc4011fd"} Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
Message from Ian Lance Taylor: Patch Set 5: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
Message from Go LUCI: Patch Set 5: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
Message from Go LUCI: Patch Set 5: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
This PR (HEAD: b0cce21) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/term/+/603957. Important tips:
|
Message from Laurent Demailly: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/603957. |
…ally add to the History and let the caller of ReadLine() decide, for instance to only add validated commands
f0c4fc2
to
972077b
Compare
This PR (HEAD: 972077b) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/term/+/603957. Important tips:
|
…faultHistoryEntries as const
This PR (HEAD: 68dd89e) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/term/+/603957. Important tips:
|
This PR (HEAD: aa00721) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/term/+/603957. Important tips:
|
aa00721
to
26ecfd1
Compare
This PR (HEAD: 26ecfd1) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/term/+/603957. Important tips:
|
In order for users of the library to save and restore the history, expose:
History() []string
: returns a slice of strings containing the history of entered commands so far.AddToHistory(cmd ...string)
: populates history.NewHistory(capacity int)
: resets the history to a new one of the given capacity.AutoHistory(bool)
sets whether lines are automatically added to the history (defaults remains true).ReplaceLatest(entry string) string
replaces the most recent entry (useful for correcting invalid commands).Also avoid adding adjacent exact duplicates to the history (consuming slots unnecessarily)
Added a test, more comments, and expose the
100
default history constant.Demonstration of use fortio/terminal@77eee7b
Fixes golang/go#68780