Skip to content
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

Add NewStderrWriter #102

Merged
merged 2 commits into from
Oct 23, 2018
Merged

Add NewStderrWriter #102

merged 2 commits into from
Oct 23, 2018

Conversation

c-bata
Copy link
Owner

@c-bata c-bata commented Oct 20, 2018

Add NewStderrWriter to support stderr output. To close #101

Usage is like this:

package main

import (
	"fmt"

	"github.com/c-bata/go-prompt"
)

func completer(in prompt.Document) []prompt.Suggest {
	s := []prompt.Suggest{
		{Text: "users", Description: "Store the username and age"},
		{Text: "articles", Description: "Store the article text posted by user"},
		{Text: "comments", Description: "Store the text commented to articles"},
		{Text: "groups", Description: "Combine users with specific rules"},
	}
	return prompt.FilterHasPrefix(s, in.GetWordBeforeCursor(), true)
}

func main() {
	in := prompt.Input(">>> ", completer,
		prompt.OptionWriter(prompt.NewStderrWriter()))  // <- set stderr writer
	fmt.Println("Your input: " + in)
}

// NewStandardOutputWriter returns ConsoleWriter object to write to stdout.
var (
// Deprecated: Please use NewStdoutWriter
NewStandardOutputWriter = NewStdoutWriter
Copy link
Owner Author

@c-bata c-bata Oct 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecate NewStandardOutputWriter because it's a little bit long :(

@rhysd
Copy link
Contributor

rhysd commented Oct 23, 2018

Looks good for me. Please add 'Closes #101' to description of this PR or commit message since this PR resolves the same problem as what #101 wants to resolve.

@c-bata
Copy link
Owner Author

c-bata commented Oct 23, 2018

Thanks. I changed a description of this PR. I'll merge this.

@c-bata c-bata merged commit 1e50403 into master Oct 23, 2018
@c-bata c-bata deleted the add-stderr-writer branch October 23, 2018 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants