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

Silence Usage When an Error Occurs #292

Merged
merged 1 commit into from
Sep 9, 2019
Merged

Silence Usage When an Error Occurs #292

merged 1 commit into from
Sep 9, 2019

Conversation

danielhelfand
Copy link
Member

@danielhelfand danielhelfand commented Sep 6, 2019

This pull request partially addresses #183. It sets SilenceUsage: true in root.go so the help message for each command does not display when an error occurs.

Previously, when an error was displayed, the usage of the command would display. An example is below:

$ tkn pr ls -n 
Error: flag needs an argument: 'n' in -n
Usage:
  tkn pipelinerun list [flags]

Aliases:
  list, ls

Examples:

# List all PipelineRuns of Pipeline name 'foo'
tkn pipelinerun list foo -n bar

# List all pipelineruns in a namespaces 'foo'
tkn pr list -n foo",


Flags:
      --allow-missing-template-keys   If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
  -h, --help                          help for list
  -o, --output string                 Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
      --template string               Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].

Global Flags:
  -k, --kubeconfig string   kubectl config file (default: $HOME/.kube/config)
  -n, --namespace string    namespace to use (default: from $KUBECONFIG)

With the change in this pr, the output would change to the following:

$ tkn pr ls -n 
Error: flag needs an argument: 'n' in -n

My opinion is that displaying all the --help information makes the error message difficult to find and is much more information than the user needs to solve the situation.

What is still needed is an elegant way to suggest to the user to run --help for the specific subcommand. I am open to any suggestions that can happen as part of this pr or can be discussed in #183. This is something that looks like it is being discussed in the Cobra project.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

Release Notes

Error messages no longer display the usage of the CLI command for which the error occurred. 

@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 6, 2019
@tekton-robot
Copy link
Contributor

Hi @danielhelfand. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 6, 2019
@chmouel
Copy link
Member

chmouel commented Sep 8, 2019

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 8, 2019
Copy link
Member

@sthaha sthaha left a comment

Choose a reason for hiding this comment

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

@danielhelfand looks good to me; did you see if there are any associated doc changes i.e. did you run make man docs ?

@danielhelfand
Copy link
Member Author

@sthaha Just ran make man docs and not seeing any changes.

@sthaha
Copy link
Member

sthaha commented Sep 9, 2019

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 9, 2019
@sthaha sthaha self-requested a review September 9, 2019 03:09
@sthaha
Copy link
Member

sthaha commented Sep 9, 2019

/lgtm

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielhelfand, sthaha

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 9, 2019
@tekton-robot tekton-robot merged commit ab5f516 into tektoncd:master Sep 9, 2019
chmouel added a commit that referenced this pull request Sep 26, 2019
#290 | [Chmouel Boudjnah] Add rainbow colouring of the steps | 2019/09/08-05:36
#292 | [danielhelfand] add SilenceUsage: true to root.go | 2019/09/08-22:11
#293 | [Carlos Santana] Update install instructions in readme to 0.3.1 | 2019/09/08-23:39
#279 | [16yuki0702] Add deletion scenario to e2e test | 2019/09/09-02:17
#279 | [16yuki0702] Fix to use -f flag | 2019/09/09-02:17
#300 | [Chmouel Boudjnah] Use a older version of thrift | 2019/09/09-08:48
#300 | [Chmouel Boudjnah] Don't run go mod vendor on every build | 2019/09/09-08:48
#301 | [Chmouel Boudjnah] E2E tests fixes | 2019/09/09-12:00
#303 | [danielhelfand] add taskrun describe command | 2019/09/10-02:15
#304 | [16yuki0702] Fix document typos | 2019/09/10-04:45
null | [Piyush Garg] Fix interactive prompt with --last | 2019/09/10-07:04
null | [16yuki0702] Add canceling feature to taskrun command | 2019/09/10-08:23
null | [Chmouel Boudjnah] Improve release script | 2019/09/11-10:35
null | [Sunil Thaha] Doc: Improve taskrun help example | 2019/09/12-02:09
null | [Piyush Garg] Fix -n not working with pipeline logs | 2019/09/12-02:23
null | [Piyush Garg] Show descriptive failure message | 2019/09/12-03:36
null | [danielhelfand] change error message returned by task for namespace | 2019/09/16-06:48
null | [Chmouel Boudjnah] Add a Tasrun to build rpm. | 2019/09/17-01:52
null | [Chmouel Boudjnah] Add information about copr rpm package repo in README | 2019/09/17-01:52
null | [Chmouel Boudjnah] Use khuram spec files which does a proper source build | 2019/09/17-01:52
null | [Chmouel Boudjnah] Update README with distros supported for dnf install | 2019/09/17-01:52
null | [Nikhil Thomas] Fix CI breakage | 2019/09/19-23:57
null | [Andrea Frittoli] Fix the logs command when creating a pipelinerun | 2019/09/20-01:57
null | [16yuki0702] Adding missing copyright header | 2019/09/23-04:47
null | [danielhelfand] correct copr package section typos | 2019/09/23-08:38
null | [danielhelfand] align pipeline describe output with other describe commands | 2019/09/24-04:58
null | [Chmouel Boudjnah] Add no colour option | 2019/09/24-05:24
null | [Chmouel Boudjnah] Disable nocolour test | 2019/09/24-05:24
null | [Chmouel Boudjnah] Generate documentation | 2019/09/24-05:24
null | [danielhelfand] align output with task describe command | 2019/09/24-05:36
null | [cappyzawa] fix misspell based on https://goreportcard.com/report/github.com/tektoncd/cli#misspell | 2019/09/24-06:20
null | [danielhelfand] add check to taskrun cancel for already executed taskrun | 2019/09/24-07:56
null | [Pradeep Kumar] Common method to get last run for a pipeline | 2019/09/24-08:17
null | [Pradeep Kumar] correts imports order | 2019/09/24-08:17
null | [Andrea Frittoli] Improve the error message on pipeline create | 2019/09/24-09:40
null | [Andrea Frittoli] Fix the logs command when creating a pipelinerun | 2019/09/24-09:40
null | [danielhelfand] add check to pipelinerun cancel for already executed pipelinerun | 2019/09/25-09:11
null | [Vincent Demeester] Bump tektoncd/pipeline to 0.7.x | 2019/09/25-10:02
null | [Vincent Demeester] bump github.com/AlecAivazis/survey/v2 to v2.0.4 | 2019/09/25-10:02
null | [Khurram Baig] Add Vendored Dependencies to RPM Spec | 2019/09/26-03:03

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
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. cla: yes lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants