fix: NullIndicator for truly silent TUI mode - no stdout at all
This commit is contained in:
@ -4,8 +4,8 @@ This directory contains pre-compiled binaries for the DB Backup Tool across mult
|
|||||||
|
|
||||||
## Build Information
|
## Build Information
|
||||||
- **Version**: 1.1.0
|
- **Version**: 1.1.0
|
||||||
- **Build Time**: 2025-11-05_13:46:28_UTC
|
- **Build Time**: 2025-11-05_13:55:03_UTC
|
||||||
- **Git Commit**: 07b3c74
|
- **Git Commit**: e2596c4
|
||||||
|
|
||||||
## Recent Updates (v1.1.0)
|
## Recent Updates (v1.1.0)
|
||||||
- ✅ Fixed TUI progress display with line-by-line output
|
- ✅ Fixed TUI progress display with line-by-line output
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -62,6 +62,11 @@ func NewWithProgress(cfg *config.Config, log logger.Logger, db database.Database
|
|||||||
|
|
||||||
// NewSilent creates a new backup engine in silent mode (for TUI)
|
// NewSilent creates a new backup engine in silent mode (for TUI)
|
||||||
func NewSilent(cfg *config.Config, log logger.Logger, db database.Database, progressIndicator progress.Indicator) *Engine {
|
func NewSilent(cfg *config.Config, log logger.Logger, db database.Database, progressIndicator progress.Indicator) *Engine {
|
||||||
|
// If no indicator provided, use null indicator (no output)
|
||||||
|
if progressIndicator == nil {
|
||||||
|
progressIndicator = progress.NewNullIndicator()
|
||||||
|
}
|
||||||
|
|
||||||
detailedReporter := progress.NewDetailedReporter(progressIndicator, &loggerAdapter{logger: log})
|
detailedReporter := progress.NewDetailedReporter(progressIndicator, &loggerAdapter{logger: log})
|
||||||
|
|
||||||
return &Engine{
|
return &Engine{
|
||||||
@ -278,9 +283,16 @@ func (e *Engine) BackupCluster(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a quiet progress indicator to avoid duplicate messages
|
// Use appropriate progress indicator based on silent mode
|
||||||
quietProgress := progress.NewQuietLineByLine()
|
var quietProgress progress.Indicator
|
||||||
quietProgress.Start("Starting cluster backup (all databases)")
|
if e.silent {
|
||||||
|
// In silent mode (TUI), use null indicator - no stdout output at all
|
||||||
|
quietProgress = progress.NewNullIndicator()
|
||||||
|
} else {
|
||||||
|
// In CLI mode, use quiet line-by-line output
|
||||||
|
quietProgress = progress.NewQuietLineByLine()
|
||||||
|
quietProgress.Start("Starting cluster backup (all databases)")
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure backup directory exists
|
// Ensure backup directory exists
|
||||||
if err := os.MkdirAll(e.cfg.BackupDir, 0755); err != nil {
|
if err := os.MkdirAll(e.cfg.BackupDir, 0755); err != nil {
|
||||||
|
|||||||
@ -395,4 +395,18 @@ func NewIndicator(interactive bool, indicatorType string) Indicator {
|
|||||||
default:
|
default:
|
||||||
return NewLineByLine() // Default to line-by-line for better compatibility
|
return NewLineByLine() // Default to line-by-line for better compatibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NullIndicator is a no-op indicator that produces no output (for TUI mode)
|
||||||
|
type NullIndicator struct{}
|
||||||
|
|
||||||
|
// NewNullIndicator creates an indicator that does nothing
|
||||||
|
func NewNullIndicator() *NullIndicator {
|
||||||
|
return &NullIndicator{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *NullIndicator) Start(message string) {}
|
||||||
|
func (n *NullIndicator) Update(message string) {}
|
||||||
|
func (n *NullIndicator) Complete(message string) {}
|
||||||
|
func (n *NullIndicator) Fail(message string) {}
|
||||||
|
func (n *NullIndicator) Stop() {}
|
||||||
Reference in New Issue
Block a user