-
Notifications
You must be signed in to change notification settings - Fork 48
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
Extract text package from gh #69
Conversation
@@ -207,43 +206,16 @@ func timeAgo(ago time.Duration) string { | |||
return "just now" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of weird that we don't use FuzzyAgo
instead of this entire function. Perhaps we should be? The current functionality was brought over from gh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel pretty good about this extraction, only thing I am a bit concerned about is the clarity of the comments. Any feedback there is appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text-package
6af1689
to
6e59115
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would vote to remove most of the functions there and focus on just the handful of ones that we want to control the implementation of, such as ANSI-codes aware implementations of measuring display width, truncation, and indentation.
Unlike in Ruby or JavaScript, offering a grab-bag of tiny utilities as a Go library isn't what most Go developers want. In fact, if they need some of these utilities in their own programs, most Go developers might choose to just inline them there instead of adding a dependency. Of course, gh extension authors will already depend on the go-gh repository anyway, but at least we can reduce the surface of the APIs we offer.
} | ||
|
||
// Pluralize returns a concatenated string with num and the plural form of thing if necessary. | ||
func Pluralize(num int, thing string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that such simplistic pluralization implementation should best be inlined in people's extensions (if needed at all) instead of being exposed from go-gh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is simplistic, but it is necessary for FuzzyAgo
and also used independently of that in gh
so if it isn't exposed here then it will need to be duplicated in gh
. Going to leave it in for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mislav Thanks for the review. I made the requested changes if you wouldn't mind giving it another look 🙇
} | ||
|
||
// Pluralize returns a concatenated string with num and the plural form of thing if necessary. | ||
func Pluralize(num int, thing string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is simplistic, but it is necessary for FuzzyAgo
and also used independently of that in gh
so if it isn't exposed here then it will need to be duplicated in gh
. Going to leave it in for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🚀
This PR extracts the text package from
gh
. It also includesFuzzyAgo
andFuzzyAgoAbbr
from theutils
package because they seemed to fit in well here.cc cli/cli#5544