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

init(coloring): add same coloring to all #38

Merged
merged 11 commits into from
Oct 23, 2022

Conversation

georgettica
Copy link
Contributor

from this base I can trickle the coloring into anywhere I need

@ghost
Copy link

ghost commented Oct 10, 2022

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@codecov
Copy link

codecov bot commented Oct 10, 2022

Codecov Report

Base: 100.00% // Head: 79.68% // Decreases project coverage by -20.31% ⚠️

Coverage data is based on head (1d57a1d) compared to base (d616de5).
Patch coverage: 68.29% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##            master      #38       +/-   ##
============================================
- Coverage   100.00%   79.68%   -20.32%     
============================================
  Files            1        2        +1     
  Lines           36       64       +28     
============================================
+ Hits            36       51       +15     
- Misses           0       11       +11     
- Partials         0        2        +2     
Impacted Files Coverage Δ
httpref.go 100.00% <ø> (ø)
view.go 68.29% <68.29%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@georgettica
Copy link
Contributor Author

this is a bit tangled up, and currently just shows a big blob of color, this is why I wanted a designer to look at it now :)

@georgettica
Copy link
Contributor Author

related to #34

@georgettica
Copy link
Contributor Author

design rought outline:
title in color
description in grey
code in special color (red / yellow / etc)

@georgettica georgettica marked this pull request as ready for review October 14, 2022 12:13
cmd/root.go Outdated
Comment on lines 109 to 122
if !isStylePopulated {
isStylePopulated = true
baseRootStyle = lipgloss.NewStyle().Width(width)
}
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we need to protect this bit with a bool. isStylePopulated isn't actually set elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but the func is happening multiple times, I can set it each time if it's clearer

view.go Outdated
)

var (
resultStyle, nameStyle, summaryStyle lipgloss.Style
Copy link
Owner

Choose a reason for hiding this comment

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

resultStyle doesn't appear to be consumed anywhere, might be worth removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resultStyle was the base style before using the style I got from the caller, so removed

view.go Outdated

func PrintResultsWithStyle(results References, rootStyle lipgloss.Style) {
// doing the population in a point where the width should not change anymore
if !areStylesPopulated {
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure we need this bool either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a different func, thus styles need to be set here aswell

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so it is required

view.go Outdated
Comment on lines 39 to 62
func renderStyles(baseStyle lipgloss.Style) {
resultStyle = baseStyle.Copy()
nameStyle = baseStyle.Copy().
Foreground(lipgloss.Color("86")).
Bold(true).
Underline(true)

summaryStyle = baseStyle.Copy()
r, err := glamour.NewTermRenderer(
// detect background color and pick either the default dark or light theme
glamour.WithAutoStyle(),
// wrap output at specific width (default is 80)
glamour.WithWordWrap(baseStyle.GetWidth()),
)
if err != nil {
// hoping this doesn't happen as most commands here suceed without issue
panic(err)
}
descriptionStyle = r
}
Copy link
Owner

Choose a reason for hiding this comment

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

I like how this function sets the style but not keen on the use of global scope variables. Maybe return the different styles so that can be consumed in PrintResultsWithSyle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I can return a style but this means I need to decide each time which style is what I want.

I'll do that and we'll see how it looks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tried that and it makes me inject the styles all the way down

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnnrly do you think it's ok to close it? if so feel free to do so

@dnnrly
Copy link
Owner

dnnrly commented Oct 15, 2022

I don't suppose you've been able to run the unit and acceptance tests? They obviously run as part of the checks for this PR but I've not been able to get them to work locally. Have you been able to get them to work? Linting too.

$ make ci-test
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
# github.com/dnnrly/httpref [github.com/dnnrly/httpref.test]
./httpref_test.go:71:19: too many arguments in call to r.Summarize
	have (number)
	want ()
./httpref_test.go:84:19: too many arguments in call to r.Summarize
	have (number)
	want ()
./httpref_test.go:92:28: too many arguments in call to r.Describe
	have (number)
	want ()
FAIL	github.com/dnnrly/httpref [build failed]
?   	github.com/dnnrly/httpref/cmd	[no test files]
?   	github.com/dnnrly/httpref/cmd/httpref	[no test files]
ok  	github.com/dnnrly/httpref/test	0.044s	coverage: [no statements] [no tests to run]
FAIL
make: *** [Makefile:76: ci-test] Error 2

@georgettica
Copy link
Contributor Author

I just ran the normal tests, sry :( I'll get them to work too

@georgettica
Copy link
Contributor Author

@dnnrly then why did the CI pass then?

@dnnrly
Copy link
Owner

dnnrly commented Oct 16, 2022

I'm really not sure why. I spent some time last night trying to figure out why and didn't get anywhere.

Mind if I push a couple of changed to see if we can get to the bottom of it?

@georgettica
Copy link
Contributor Author

sure!
I can always rebase and fix the conflicts later

@georgettica
Copy link
Contributor Author

please do let me know when you have fixed the CI issue

@dnnrly
Copy link
Owner

dnnrly commented Oct 19, 2022

I think I've fixed the issue but you'll have to rebase your branch on top of master.

@georgettica
Copy link
Contributor Author

of course, no worries

othorotka and others added 6 commits October 22, 2022 14:54
from this base I can trickle the coloring into anywhere I need
for pretty printing the description
to make the description colorful
Co-authored-by: Pascal Dennerly <[email protected]>
@georgettica georgettica force-pushed the feature/georgettica/add-coloring branch from 054c833 to 52b1e7b Compare October 22, 2022 11:54
- remove the if statement
@georgettica
Copy link
Contributor Author

so now there is another issue, not sure exactly how to move forward from it.
line too long or something (and the message is not clear for me in the test)

PS now also the make test fails

@dnnrly
Copy link
Owner

dnnrly commented Oct 22, 2022

I wonder if it's something to do with the formatting markup in the terminal. I'll take a look.

- Removed a test that just asserted that the formatting library works as specified.
- This is checking that the formatter is formatting again so the test clause should be removed.
@dnnrly
Copy link
Owner

dnnrly commented Oct 22, 2022

I think I sorted the test failures (I may have cheated a little). Only thing now is to make the test coverage adequate. Maybe make PrintResultsWithStyle return an error instead?

@georgettica
Copy link
Contributor Author

yeah, that is the right way of doing things and I didn't want to bubble it up.
will do it tomorrow I guess

@georgettica
Copy link
Contributor Author

and thanks for the help!

@dnnrly
Copy link
Owner

dnnrly commented Oct 23, 2022

This is more than good enough. Anything important can be dealt with in other PRs. Thanks for your help in this!!!

I'm going to be away from the computer for a little bit so I'm just merging as-is.

@dnnrly dnnrly merged commit c726fe1 into dnnrly:master Oct 23, 2022
@georgettica georgettica deleted the feature/georgettica/add-coloring branch October 24, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants