-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add grouping for help message + streamlined help messages #887
Conversation
The top-level looks like kn is the command line interface for managing Knative Serving and Eventing objects Find more information about Knative at: https://knative.dev Serving Commands: service Manage Knative services revision Manage service revisions route List and show service routes Eventing Commands: source Manage event sources trigger Manage event triggers Other Commands: plugin Manage kn plugins completion Output shell completion code version Show the version of this client Use "kn <command> --help" for more information about a given command. Use "kn options" for a list of global command-line options (applies to all commands). The following changes have been applied: * Add CommandGroups for grouping commands together * Add flexible templating for the help messages * Moved global options to an own command ('kn options', much like 'kubectl options') * Aligned wording and typography of help messages These features has been highly inspired by kubectl grouping & help templating but has been considerably been stripped down to the needs of kn. Signed-off-by: Roland Huß <[email protected]>
Please note that testing still needs to be added, this PR is however already open for review to gather early feedback. |
Co-authored-by: Matt Moore <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally for #885 and seems to resolve the issue.
Some general comments would be to check for error messages that already include the prefix to avoid double prints, such as here. Maybe that's handled, but in general should be removed and discouraged in the future.
Also, maybe including the error prefix in some tests is worthwhile as a means of verifying the error prefix?
Edit: I see the note on testing.
Looks good to me otherwise.
Since there is a single exit point we are free to mangle the error message as we want. But I consider this more like a workaround since adding an "error: " prefix in an error message looks quite redundant (it's clear that it is an error if the prefix is part of an error message, also the formatting of the error message should be left to the layer which deals with the error). However, we don't have much influence on the wording of errors returned from library calls. I will add some tests to check the error wording. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v wire_gen.go)
Added the missing testing bits. |
/assign |
/retest |
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
rootCmd.SetHelpFunc(engine.helpFunc()) | ||
} | ||
|
||
func setHelpFlagsToSubCommands(parent *cobra.Command) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is removing [flags]
from the usage line, we may rename this to disableFlagsInUseLine
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it adds "[options]" instead of "[flags]" --> https://github.com/rhuss/knative-client/blob/41338722cdc2124dda2b3a594527749a31d8b735/pkg/templates/template_engine.go#L134
Again, inline with kubectl
and "options" is a good wording here, as all the rest is just optional. Everything mandatory should be mentioned in the "Use" attribute.
/test pull-knative-client-integration-tests-latest-release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. I like the consolidations and some simplication though there are various places where text is repeated and/or not adding anything useful, perhaps best to omit or remove, .e.g, Synopis of source apiserver
and various places. Left a few other specific comments.
Did not review the templating section. I see that @navidshaikh is reviewing. I might take a pass after.
|
||
### Synopsis | ||
|
||
Provides utilities for interacting and managing with kn plugins. | ||
Manage kn plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also mention the client-contrib
here as a place to find "vetted" plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for this but maybe we should have a first release for the client-contrib plugins. We can add this info any time with a link to a consolidated list.
@@ -1,13 +1,13 @@ | |||
## kn source apiserver list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this read: "## kn source api-server list" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment below.
|
||
### Synopsis | ||
|
||
Delete a sink binding. | ||
Delete a sink binding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder how useful the Synopsis is when its the same text as the general description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is due to the way how the docs are generated and that the BindingDeleteCommand
doesn't have a Long
description (so the short description is reused).
We should add to every command a longer descriptions (if it makes sense, here e.g. one could add a brief explanation what a sink binding is, maybe with a link to the binding docs).
As this PR doesn't change anything with regard to the Long description, I'd suggest to open a new issue for this and work separately on consolidating the long descriptions.
@@ -26,8 +26,8 @@ import ( | |||
// NewAPIServerCommand for managing ApiServer source | |||
func NewAPIServerCommand(p *commands.KnParams) *cobra.Command { | |||
apiServerSourceCmd := &cobra.Command{ | |||
Use: "apiserver", | |||
Short: "Kubernetes API Server Event Source command group", | |||
Use: "apiserver COMMAND", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be api-server COMMAND
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We settled on apiserver
for the command (like in kn source apiserver list
), so changing it now would be backwards incompatible. We could do this if its improve the UX considerably but should be aware that it involves more work than just renaming it here.
What we can do though is to add an alias api-server
for apiserver
alongside the suggestions in #812 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:+1 for alias
pkg/kn/commands/testing_helper.go
Outdated
type StdoutCapture struct { | ||
r, w *os.File | ||
t *testing.T | ||
type OutputCapture struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this testing_helper.go
should move to lib/test
to make it useable in client-contrib
plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, going to move it over there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved the OutputCapture
to lib/test
.
I think the other parts are more for internally testing KnCommands
that is specific of how kn
organizes it commands (also there might be some change here, too).
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/retest
/lgtm
/approve
thanks!
aliases could be the next thing to look at..
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: navidshaikh, rhuss 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 |
@rhuss : CHANGELOG missing, lets bring it in another PR |
Thanks ! |
The top-level looks like
The following changes have been applied:
These features has been highly inspired by kubectl grouping & help templating but has been considerably been stripped down to the needs of kn.
Fixes #579