Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set flagset to ExitOnError for command #1633

Closed
tasherif-msft opened this issue Mar 16, 2022 · 5 comments · May be fixed by #1662
Closed

Cannot set flagset to ExitOnError for command #1633

tasherif-msft opened this issue Mar 16, 2022 · 5 comments · May be fixed by #1662
Labels
area/flags-args Changes to functionality around command line flags and args kind/bug A bug in cobra; unintended behavior triage/needs-triage Needs to be placed into a milestone or be closed by maintainers

Comments

@tasherif-msft
Copy link

When creating a new command I'm unable to set the Flagset to ExitOnError
The setting to ContinueOnError causes cases where the return error code is 0 even though something has went wrong.

For example:

@marckhouzam
Copy link
Collaborator

Maybe related to #582, #922, #1305, which is something we are having trouble fixing due to backwards-compatibility concerns.

@tasherif-msft can you provide a small example to reproduce the problem to better understand if this is the same or a different issue?

@tasherif-msft
Copy link
Author

Hi @marckhouzam, yes it appears that this is a known issue then - I'm wondering is it not possible to create a new method that would accept this enum as a parameter when initializing the flatset?

@jpmcb jpmcb added kind/bug A bug in cobra; unintended behavior area/flags-args Changes to functionality around command line flags and args triage/needs-triage Needs to be placed into a milestone or be closed by maintainers labels Mar 25, 2022
@gapra-msft
Copy link

Hi @marckhouzam

Here is a minimal repro

https://go.dev/play/p/Ge_P9YLn_gO

If you run this command from the command line locally and run echo $? You should see the exit code set to 0.

@gapra-msft
Copy link

Hi @marckhouzam and @jpmcb,

I've created a draft PR of a possible solution to this problem. Could you take a look and see if it looks feasible? Then I can add some tests and open the PR.

#1662

@github-actions
Copy link

The Cobra project currently lacks enough contributors to adequately respond to all issues. This bot triages issues and PRs according to the following rules:

  • After 60d of inactivity, lifecycle/stale is applied. - After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied and the issue is closed.
    You can:
  • Make a comment to remove the stale label and show your support. The 60 days reset. - If an issue has lifecycle/rotten and is closed, comment and ask maintainers if they'd be interseted in reopening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/flags-args Changes to functionality around command line flags and args kind/bug A bug in cobra; unintended behavior triage/needs-triage Needs to be placed into a milestone or be closed by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants