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

🌱 pkg/cli: fix lack of help when --help is set #1900

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

estroz
Copy link
Contributor

@estroz estroz commented Dec 11, 2020

#1828 removed --help handling so that kubebuilder -h will only print

$ kubebuilder -h
Usage of base:
      --plugins string           plugins to run
      --project-version string   project version
pflag: help requested

/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 11, 2020
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 11, 2020
@DirectXMan12
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 11, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12, estroz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [DirectXMan12,estroz]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 30df583 into kubernetes-sigs:master Dec 11, 2020
@estroz estroz deleted the bugfix/add-help branch December 11, 2020 21:53
Copy link
Contributor

@Adirio Adirio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@estroz I thought that I was able to find a way to print the help message without this special case. Could you elaborate on the behavior that you consider broken?

(I know it is merged already)

// User needs *generic* help if args are incorrect or --help is set and
// --project-version is not set. Plugin-specific help is given if a
// plugin.Context is updated, which does not require this field.
c.doHelp = err != nil || help && !fs.Lookup(projectVersionFlag).Changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err == nil always due to how flags are parsed ( plfag.ExitOnError and pflag.ParseErrorsWhitelist{UnknownFlags: true}).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While true, code should handle every error where possible in case library behavior changes.

@estroz
Copy link
Contributor Author

estroz commented Dec 11, 2020

I think the problem was that somehow flag parsing was ending in getInfoFromFlags() when --help was set (see output in the description), and flags weren't being passed to the actual flagset in cli. There might be a bug somewhere else causing this, but at least now I've reverted --help behavior to its pre-#1828 state.

@Adirio
Copy link
Contributor

Adirio commented Dec 12, 2020

It says Usage of base and base is the name given to the temporal flagset used to pre-decode these two arguments. WIll investigate a bit further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants