Skip to content

Conversation

sayan-biswas
Copy link
Contributor

@sayan-biswas sayan-biswas commented Sep 3, 2025

Changes

  • Discard any messages or error written to stdio or stderr by goflag library. Return the error only.
  • In case of error while parsing the goflags, print the error, then print the CLI help and then exit with 1.

Fixes #346

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Fixes CLI output when incorrect flags are passed.

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 3, 2025
Fixes shipwright-io#346

# Changes:
- Discard any messages or error written to stdio or stderr by goflag library. Return the error only.
- In case of error while parsing the goflags, print the error, then print the CLI help and then exit with 1.

Signed-off-by: Sayan Biswas <[email protected]>
@sayan-biswas
Copy link
Contributor Author

/cc @adambkaplan

@openshift-ci openshift-ci bot requested a review from adambkaplan September 3, 2025 19:57
Copy link

@avinal avinal left a comment

Choose a reason for hiding this comment

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

Works as expected.

Test output:

➜  shp-cli git:(fix-help-version) ./shp --version
ERROR: flag provided but not defined: -version

Command-line client for Shipwright's Build API.

Usage:
  shp [command] [resource] [flags]
  shp [command]

Available Commands:
  build                Manage Builds
  buildrun             Manage BuildRuns
  buildstrategy        Manage namespaced BuildStrategies
  clusterbuildstrategy Manage cluster-scoped BuildStrategies
  version              version

Flags:
      --kubeconfig string        Path to the kubeconfig file to use for CLI requests.
  -n, --namespace string         If present, the namespace scope for this CLI request
      --request-timeout string   The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")

Use "shp [command] --help" for more information about a command.

Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/approve

/lgtm

While normally I wouldn't merge this for the sake of release stability, this is a highly visible bug fix that carries low risk.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2025
Copy link
Contributor

openshift-ci bot commented Sep 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2025
@adambkaplan adambkaplan added this to the release-v0.17.0 milestone Sep 5, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit c155d3c into shipwright-io:main Sep 5, 2025
10 checks passed
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. lgtm Indicates that a PR is ready to be merged. release-note size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] CLI when used with incorrect flag, prints unecessary information and hidden flags
3 participants