Files

41 lines
938 B
Go
Raw Permalink Normal View History

package flows
import "github.com/safedep/pmg/internal/ui"
// inferOutcome determines the execution outcome based on configuration and execution data.
//
// Outcome precedence:
// 1. Error (if no packages were blocked)
// 2. Insecure installation bypass
// 3. Dry run mode
// 4. User cancellation
// 5. Packages blocked
// 6. Success (default)
func inferOutcome(insecureMode, dryRun bool, blockedCount, userCancelledCount int, err error) ui.ExecutionOutcome {
// Error takes precedence unless we have blocked packages
if err != nil && blockedCount == 0 {
return ui.OutcomeError
}
// Config-based outcomes
if insecureMode {
return ui.OutcomeInsecureBypass
}
if dryRun {
return ui.OutcomeDryRun
}
// User cancellation
if userCancelledCount > 0 {
return ui.OutcomeUserCancelled
}
// Blocked packages take precedence over errors
if blockedCount > 0 {
return ui.OutcomeBlocked
}
return ui.OutcomeSuccess
}