-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Improvements to CLI usability and maintainability #34502
Improvements to CLI usability and maintainability #34502
Conversation
@fabianofranz great job 👍 |
func AddAdditionalCommands(g CommandGroups, message string, cmds []*cobra.Command) CommandGroups { | ||
group := CommandGroup{Message: message} | ||
for _, c := range cmds { | ||
// Don't show commands that has no short 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.
s/has/have/
e90490d
to
ad9e8d1
Compare
ad9e8d1
to
8e0dfdb
Compare
8e0dfdb
to
832e644
Compare
Jenkins verification failed for commit 832e644. Full PR test history. The magic incantation to run this job again is |
It is intended to store non-identifying auxiliary data, especially data manipulated by tools and system extensions. | ||
If --overwrite is true, then existing annotations can be overwritten, otherwise attempting to overwrite an annotation will result in an error. | ||
If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used. | ||
* An annotation is a key/value pair that can hold larger (compared to a label), and possibly not human-readable, data. |
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.
why add *
here?
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.
It's list items. Not strictly required, but if we don't use list items here we have to either give each one its own paragraph, or make it all part of a single paragraph (no line wrapping). Markdown unwraps single line breaks.
set -o pipefail | ||
|
||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||
source "${KUBE_ROOT}/hack/lib/init.sh" |
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.
whether we should add this check to normal verify process? like check this when commit.
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.
Yep, it does it already. verify
runs everything that satisfies hack/verify-*.sh
, which includes this one.
ad9e32e
to
ff913f0
Compare
ff913f0
to
24784ef
Compare
What else? I'd like to get this in when possible given rebases here are painful. :) |
|
||
const linebreak = "\n" | ||
|
||
// ASCIIRenderer is a blackfriday rendered intended for rendering markdown |
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.
Can you add a
var _ blackfriday.Renderer = ASCIIRenderer{}
to make it explicit that we are conforming to an external interface?
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.
Done!
`{{$rootCmd := rootCmd .}}` + | ||
`{{$visibleFlags := visibleFlags (flagsNotIntersected .LocalFlags .PersistentFlags)}}` + | ||
`{{$explicitlyExposedFlags := exposed .}}` + | ||
`{{$optionsCmdFor := optionsCmdFor .}}` + | ||
`{{$usageLine := usageLine .}}` | ||
|
||
mainHelpTemplate = `{{with or .Long .Short }}{{. | trim}}{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}` | ||
SectionAliases = `{{if gt .Aliases 0}}Aliases: |
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.
Can you add godoc to these constants?
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.
Godoc added.
w := NewMaxWidthWriter(b, tc.maxWidth) | ||
_, err := w.Write([]byte(tc.input)) | ||
if err != nil { | ||
t.Errorf("%s: Unexpected error: '%s'", k, err) |
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.
%v for errors - otherwise you can use %q to quote by default and use err.Error() instead of err
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 catch, fixed.
Added a few more comments but looks good overall. |
24784ef
to
c5044ac
Compare
@Kargakis all comments addressed, thanks! |
c5044ac
to
0fd5c8d
Compare
Tagging, additional comments can be addressed in follow-ups |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
…mprovements Automatic merge from submit-queue Improvements to CLI usability and maintainability Improves `kubectl` from an usability perspective by 1. Fixing how we handle terminal width in help. Some sections like the flags use the entire available width, while others like long descriptions breaks lines but don't follow a well established max width (screenshot below). This PR adds a new responsive writer that will adjust to terminal width and set 80, 100, or 120 columns as the max width, but not more than that given POSIX best practices and recommendations for better readability. ![terminal_width](https://cloud.githubusercontent.com/assets/158611/19253184/b23a983e-8f1f-11e6-9bae-667dd5981485.png) 2. Adds our own normalizers for long descriptions and cmd examples which allows us better control about how things like lists, paragraphs, line breaks, etc are printed. Features markdown support. Looks like `templates.LongDesc` and `templates.Examples` instead of `dedent.Dedend`. 3. Allows simple reordering and reuse of help and usage sections. 3. Adds `verify-cli-conventions.sh` which intends to run tests to make sure cmd developers are using what we propose as [kubectl conventions](https://github.com/kubernetes/kubernetes/blob/master/docs/devel/kubectl-conventions.md). Just a couple simple tests for now but the framework is there and it's easy to extend. 4. Update [kubectl conventions](https://github.com/kubernetes/kubernetes/blob/master/docs/devel/kubectl-conventions.md) to use our own normalizers instead of `dedent.Dedent`. **Release note**: <!-- Steps to write your release note: 1. Use the release-note-* labels to set the release note state (if you have access) 2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. --> ```release-note Improves how 'kubectl' uses the terminal size when printing help and usage. ``` @kubernetes/kubectl
Improves
kubectl
from an usability perspective bytemplates.LongDesc
andtemplates.Examples
instead ofdedent.Dedend
.verify-cli-conventions.sh
which intends to run tests to make sure cmd developers are using what we propose as kubectl conventions. Just a couple simple tests for now but the framework is there and it's easy to extend.dedent.Dedent
.Release note:
@kubernetes/kubectl
This change is