-
Notifications
You must be signed in to change notification settings - Fork 4.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
Improves cmd descriptions and how terminal size is handled on oc help #10993
Improves cmd descriptions and how terminal size is handled on oc help #10993
Conversation
@@ -27,15 +27,15 @@ import ( | |||
exipfailover "github.com/openshift/origin/pkg/cmd/experimental/ipfailover" | |||
"github.com/openshift/origin/pkg/cmd/server/admin" | |||
"github.com/openshift/origin/pkg/cmd/templates" | |||
. "github.com/openshift/origin/pkg/cmd/templates" |
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.
Don't use .
, just use templates.LongDesc
.
I'd also prefer that we be using heredoc is combination with this, where you do auto unwrapping of paragraphs.
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.
Sounds good, it's already a dependency and kube uses it in some cmds. I'll include heredoc to the normalization logic.
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.
Actually better to use dedent
. heredoc
aligns with the smallest indentation present, meaning it can still leave indentation I don't want when doing the unwrap.
Get is moving to the server side so we'll be getting structured responses back (table of output). I think that'll probably be a similar use case, but different. We really need wrapping with indentation to solve the large non help commands (long descriptions in describe). Can this do proper indentation? |
return cmds | ||
} | ||
|
||
func setOutput(cmd *cobra.Command, out io.Writer) { |
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 a pretty drastic change - can you explain why this is necessary? Why would we not just require that all of the commands set output properly?
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.
Cascading the writer to the entire command tree would allow us, for example, to extend the use of the responsive writer for every command output (not just help) by setting it only in the root cmd.
Although it makes sense at a first glance, there are places (e.g. tables in get
) where using the max width possible also probably makes sense, so I ended up not using this and only enabling the responsive writer in help.
I'll remove this block and let us set it individually in commands where we want it.
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.
Removed,
4fc5e8d
to
f5f1c6e
Compare
14f23b7
to
e82599a
Compare
d8e41d3
to
89e31f9
Compare
1587637
to
4b4c5a5
Compare
Removing WIP here, this is good to review @openshift/cli-review @smarterclayton @jwforres
It doesn't fix the issue with indentation + long lines wrapping, but I don't think it would be hard to extend it to add something like that. It does, for example, proper indentation on multi-level lists, which is a similar concept. |
ea0bdeb
to
4b4c5a5
Compare
[test] |
ef0bd5d
to
5309135
Compare
Upstreaming in kubernetes/kubernetes#34502. |
a2ca7d0
to
47ef779
Compare
47ef779
to
284773c
Compare
UP needs review |
284773c
to
8dcddb0
Compare
flake #11240 re[test] |
1 similar comment
flake #11240 re[test] |
flake #11374 re-[test] |
585cba3
to
0aaf947
Compare
flake #11240 re[test] |
0aaf947
to
fc72a9d
Compare
Upstream merged, rebased here. |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10205/) (Image: devenv-rhel7_5206) |
Evaluated for origin merge up to fc72a9d |
flake #11240 re[test] |
Evaluated for origin test up to fc72a9d |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10205/) (Base Commit: a941850) |
Related to https://trello.com/c/04lpfTQR
We currently have a number of issues related to how the terminal width is recognized and used in the help (and actual command output) of
oc
. Some places like the flags section uses the entire terminal width, cmd descriptions limit the width but it's manual and not consistent between commands.This PR
Writer
that works in a responsive way by adjusting the help output according to the terminal size. Depending on the terminal width it will use 80, 100, or 120 columns as the max width, but not more than that given POSIX best practices and recommendations for better readability.Stdout
andStderr
).Follow-ups
Usage
at the bottom thatkubectl
uses, need to decide to either embrace it or add something like "help sections" that supports being reordered.LongDesc
.get
). We may still want wider output in some commands like that.@openshift/cli-review @jwforres