mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-02-12 02:48:39 +00:00
feat: add interactive wizard, contextual errors, and code improvements
- Add interactive configuration wizard with auto-detection and multi-format export - Implement contextual error system with 14 error codes and actionable suggestions - Add centralized progress indicators with consistent theming - Fix all cyclomatic complexity issues (8 functions refactored) - Eliminate code duplication with centralized utilities and error handling - Add comprehensive test coverage for all new components - Update TODO.md with completed tasks and accurate completion dates
This commit is contained in:
50
internal/progress.go
Normal file
50
internal/progress.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// Package internal provides progress bar utilities for the gh-action-readme tool.
|
||||
package internal
|
||||
|
||||
import (
|
||||
"github.com/schollz/progressbar/v3"
|
||||
)
|
||||
|
||||
// ProgressBarManager handles progress bar creation and management.
|
||||
type ProgressBarManager struct {
|
||||
quiet bool
|
||||
}
|
||||
|
||||
// NewProgressBarManager creates a new progress bar manager.
|
||||
func NewProgressBarManager(quiet bool) *ProgressBarManager {
|
||||
return &ProgressBarManager{
|
||||
quiet: quiet,
|
||||
}
|
||||
}
|
||||
|
||||
// CreateProgressBar creates a progress bar with standardized options.
|
||||
func (pm *ProgressBarManager) CreateProgressBar(description string, total int) *progressbar.ProgressBar {
|
||||
if total <= 1 || pm.quiet {
|
||||
return nil
|
||||
}
|
||||
|
||||
return progressbar.NewOptions(total,
|
||||
progressbar.OptionSetDescription(description),
|
||||
progressbar.OptionSetWidth(50),
|
||||
progressbar.OptionShowCount(),
|
||||
progressbar.OptionShowIts(),
|
||||
progressbar.OptionSetTheme(progressbar.Theme{
|
||||
Saucer: "=",
|
||||
SaucerHead: ">",
|
||||
SaucerPadding: " ",
|
||||
BarStart: "[",
|
||||
BarEnd: "]",
|
||||
}))
|
||||
}
|
||||
|
||||
// CreateProgressBarForFiles creates a progress bar for processing multiple files.
|
||||
func (pm *ProgressBarManager) CreateProgressBarForFiles(description string, files []string) *progressbar.ProgressBar {
|
||||
return pm.CreateProgressBar(description, len(files))
|
||||
}
|
||||
|
||||
// FinishProgressBar completes the progress bar display.
|
||||
func (pm *ProgressBarManager) FinishProgressBar(bar *progressbar.ProgressBar) {
|
||||
if bar != nil {
|
||||
_ = bar.Finish()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user