Conversation
|
fixed |
|
we've decided to ship this after a short todo list:
|
this commit is the result of April's hack day. it animates a thank you for a project's contributors. it only really works on linux/mac; animation woes led me to just make it static and plain on windows.
| return line | ||
| } | ||
|
|
||
| func twinkle(starLine string) string { |
| lines = append(lines, logins...) | ||
| lines = append(lines, "( <3 press ctrl-c to quit <3 )") | ||
|
|
||
| termWidth, termHeight, err := terminal.GetSize(int(outFile.Fd())) |
There was a problem hiding this comment.
Note that GetSize might not work on cygwin, where we had to use tput cols to measure terminal width
Lines 29 to 32 in a7242f4
There was a problem hiding this comment.
when we run under cygwin wouldn't we still see a runtime of windows?
| func clear() { | ||
| // on windows we'd do cmd := exec.Command("cmd", "/c", "cls"); unfortunately the draw speed is so | ||
| // slow that the animation is very jerky, flashy, and painful to look at. | ||
| cmd := exec.Command("clear") |
There was a problem hiding this comment.
Note: if the overhead of shelling out turns out to be too slow for us (with a 300ms refresh rate, that might not yet be the case), you can consider clearing not by running a command, but by sending terminal escape codes
fmt.Print("\033c")- clears the screen (for me, iTerm macOS)fmt.Println("\x1b[%dG")- since we draw the entire screen every time, we could get away without clearing. this repositions the printing cursor to the start of the terminal
There was a problem hiding this comment.
ah nice; it has looked fine for me on linux (so i didn't investigate speeding up) but this is great to know
command/credits.go
Outdated
|
|
||
| gh credits # see a credits animation for this project | ||
| gh credits owner/repo # see a credits animation for owner/repo | ||
| gh credts -s # display a static thank you instead of animating |
|
|
||
| RootCmd.AddCommand(creditsCmd) | ||
|
|
||
| creditsCmd.Flags().BoolP("static", "s", false, "Print a static version of the credits") |
There was a problem hiding this comment.
Perhaps instead of "static" in the description, we can say "Print a non-animated version of the credits"? If a person hasn't run credits yet, they might not realize that the default is animated, so it would be puzzling as to what "static" means
command/credits.go
Outdated
|
|
||
| func init() { | ||
| rand.Seed(time.Now().UnixNano()) | ||
| isWindows = runtime.GOOS == "windows" |
There was a problem hiding this comment.
Nit: this check is cheap and as such I don't think it needs to be cached in a variable
command/credits.go
Outdated
| ` | ||
|
|
||
| func init() { | ||
| rand.Seed(time.Now().UnixNano()) |
There was a problem hiding this comment.
Nit: since we only need to randomize seed for credits output, can we instead move this line to credits() function (and perhaps only to the animation portion)?
This is to reduce doing things in package-level init if possible
| rand.Seed(time.Now().UnixNano()) | ||
| isWindows = runtime.GOOS == "windows" | ||
|
|
||
| RootCmd.AddCommand(creditsCmd) |
There was a problem hiding this comment.
At first I was thinking that maybe this command belongs to under gh repo, e.g. gh repo credits [<repo>]. Since this command basically displays information about a given repository, grouping it together with other gh repo commands made sense to me.
However, since the default is showing credits for cli/cli (as opposed to using the current repo), for that reason alone I think it deserves to stay as top-level command.
There was a problem hiding this comment.
that was my thinking as well (about how it's mainly for seeing cli/cli's credits)
We decided to merge this into the product and it's now ready for review.
The code is Not Good but it's self-contained and introduces no new third party dependencies. There are no tests for hopefully obvious reasons.
this PR adds a new top level command,
gh credits:considerations:
cli/clibut you can specify any repo as a string (egrails/rails) and it will show contributors for that repo-smakes this intelligible by a screen reader