Skip to content

Conversation

kevingentile
Copy link

This is an attempt to resolve #1893. This logic mirrors the existing OnFinalize pattern but passes along a reference to *Command and error.

Usage:

cobra.OnFinalizeCmd(func(cmd *cobra.Command, err error) {
    if errors.Is(err, FooErr) {
        // [...]
    }
    value := cmd.Context().Value(key{})
    // [...]
})

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PersistentPostRun{,E} are not executed when RunE or PostRunE returns an error

1 participant