Skip to content

Conversation

@linkzera
Copy link
Contributor

Add configurable gradient support for progress bar

This PR introduces a new --gradient (-g) flag that allows users to customize the progress bar gradient. Users can now select from predefined presets (default, sunset, aqua, forest, fire) or specify two custom hex colors separated by a comma (e.g., --gradient=#00FF00,#0000FF). If the flag is not set or an invalid value is provided, the default gradient is used.

Features:

New --gradient flag for selecting gradient style.
Support for both presets and custom color pairs.
Updated help text to document the new flag.

@caarlos0 caarlos0 requested a review from Copilot May 20, 2025 02:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new --gradient flag to customize the progress bar gradient via presets or custom hex pairs.

  • Introduce gradientFlag and register the --gradient CLI option with help text.
  • Define gradientPresets map and select the appropriate gradient at runtime.
  • Replace the hardcoded default gradient with dynamic gradient handling in main.go.
Comments suppressed due to low confidence (1)

main.go:162

  • The new gradient parsing logic lacks unit tests. Add tests covering preset selection, custom hex parsing, and invalid-input fallback to ensure expected behavior.
var progressBar progress.Model

linkzera and others added 2 commits May 20, 2025 08:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Owner

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

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

hey, thanks for the pr

have a couple of comments

linkzera and others added 3 commits May 21, 2025 11:25
Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 requested a review from Copilot May 22, 2025 00:32
@caarlos0 caarlos0 added the enhancement New feature or request label May 22, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new --gradient flag to allow users to customize the progress bar gradient using predefined presets or two custom hex colors.

  • Introduced gradient flag and gradientPresets map.
  • Implemented logic to select a preset or parse custom hex colors.
  • Updated the Cobra command initialization to register and document the new flag.
Comments suppressed due to low confidence (2)

main.go:170

  • [nitpick] Enhance this error message by listing valid presets or the expected format to guide users (e.g. "invalid gradient %q; valid presets are %v or two hex colors separated by a comma").
return fmt.Errorf("invalid gradient %q", gradient)

main.go:218

  • Add unit tests for the new --gradient flag, covering valid presets, valid custom color pairs, and invalid inputs to ensure the parsing logic behaves as expected.
rootCmd.Flags().StringVarP(&gradient, "gradient", "g", "default", "Gradient preset (default, sunset, aqua, forest, fire) or two hex colors separated by comma (ex: --gradient=#00FF00,#0000FF)")

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@aziz0x00
Copy link

aziz0x00 commented Jan 21, 2026

Thanks @caarlos0 for the tool, and thanks @linkzera for the PR. I've been looking for this feature—looks good to merge.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants