-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Handle linebreaks in custom completions. #1162
Conversation
@marckhouzam Please take a look. |
@Luap99 Interesting find! What do you think would be best for a user:
I'm asking because I wondered if truncating a description would remove useful information. |
@marckhouzam Here are two examples I found in the podman project: I would argue that the first line should contain enough information to understand what a command/flag does. If someone wants the full information they should use the man pages or --help. |
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 tested this and it works great. Just a couple of nits on the comments.
Thanks!
ce7aad9
to
52f8696
Compare
If a command/flag description contains a linebreak then the shell completion script will interpret this as new command/flag. To fix this we only use the first line from the description in the output. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
52f8696
to
86f532b
Compare
LGTM /cc @jharshman |
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.
Thanks for this fix! LGTM 🎸
If a command/flag description contains a linebreak than the shell completion script will interpret this as new command/flag.
To fix this we should only use the first line from the description in the output.
e.g.
cmd.Flags().String("flag", "", "Description for flag\nlonger description")