Skip to content

Remove duplicate github.com/vbauerster/mpb dependency#8991

Merged
macneale4 merged 1 commit intodolthub:mainfrom
Juneezee:mpb
Mar 21, 2025
Merged

Remove duplicate github.com/vbauerster/mpb dependency#8991
macneale4 merged 1 commit intodolthub:mainfrom
Juneezee:mpb

Conversation

@Juneezee
Copy link
Copy Markdown
Contributor

"github.com/vbauerster/mpb/v8/cwriter"

"github.com/vbauerster/mpb/cwriter"

It's weird that we use the tagged v8 version in the source code but non-tagged version in the test.

@macneale4
Copy link
Copy Markdown
Contributor

What's the motivation for removing this? Seems nice to have fewer dependencies, but the code is harder to read and maintain.

@macneale4 macneale4 self-requested a review March 17, 2025 16:40
Comment on lines +66 to +76
// clearLinesTxt moves cursor up n lines, and erases from cursor position to end of screen.
// https://github.com/vbauerster/mpb/blob/v8.0.2/cwriter/writer.go#L11-L15
func clearLinesTxt(n int) string {
return fmt.Sprintf("%c[%dA", cwriter.ESC, n) + fmt.Sprintf("%c[J", cwriter.ESC)
return fmt.Sprintf("\x1b[%dA\x1b[J", n)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but the code is harder to read and maintain.

I added 2 lines of comment in case future readers find it hard to understand.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yep, I saw that. But that package isn't the spec, so kind of an odd artifact. More appropriate would be this: https://en.wikipedia.org/wiki/ANSI_escape_code#C0_control_codes

But even given that, the code to start with is poor. What does "[%dA" do for example? I already needed to know/read the spec to figure that out. I'd be happy to take a change which makes it overall more readable. The change you proposed doesn't meet that requirement.

Comment on lines -68 to +76
return fmt.Sprintf("%c[%dA", cwriter.ESC, n) + fmt.Sprintf("%c[J", cwriter.ESC)
// These are ANSI escape codes, see
// - https://en.wikipedia.org/wiki/ANSI_escape_code#C0_control_codes1
// - https://en.wikipedia.org/wiki/ANSI_escape_code#Control_Sequence_Introducer_commands
//
// \x1b: ESC (Escape)
// [%dA: CUU (Cursor Up). [5A means moves the cursor up 5 lines
// [J : ED (Erase in Display)
return fmt.Sprintf("\x1b[%dA\x1b[J", n)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@macneale4 I have added more comments. Hope you find this version easier to read.

@macneale4
Copy link
Copy Markdown
Contributor

Looks good to me. Gonna run though CI with a pr on my end

@macneale4 macneale4 merged commit 130e0be into dolthub:main Mar 21, 2025
53 of 56 checks passed
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