-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Switch help messages from using [flags] to [options] #8034
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan 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 |
71cc292
to
cc7521f
Compare
Looks like you changed Options to Flags everywhere. As other doc says Options, including RHEL doc and our other projects, we should stick with options. |
Well then you have a conflict between cmd which calls them flags. I am not sure if that can be changed, easily in podman 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.
small issues
@@ -40,7 +40,7 @@ is used. | |||
|
|||
Any additional arguments will be appended to the command. | |||
|
|||
## OPTIONS: | |||
## FLAGS: |
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.
## FLAGS: | |
## FLAGS |
Other pages do not have :
@@ -12,7 +12,7 @@ of a pod or container name or ID. | |||
|
|||
Note that the generated Kubernetes YAML file can be used to re-run the deployment via podman-play-kube(1). | |||
|
|||
## OPTIONS: | |||
## FLAGS: |
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.
## FLAGS: | |
## FLAGS |
|
||
## DESCRIPTION | ||
**podman generate systemd** will create a systemd unit file that can be used to control a container or pod. | ||
By default, the command will print the content of the unit files to stdout. | ||
|
||
_Note: If you use this command with the remote client, you would still have to place the generated units on the remote system._ | ||
|
||
## OPTIONS: | ||
## FLAGS: |
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.
## FLAGS: | |
## FLAGS |
@@ -21,7 +21,7 @@ For more inspection options, see: | |||
podman volume inspect |
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 this list be expanded to include pods and volumes?
@@ -15,7 +15,7 @@ Ideally the input file would be one created by Podman (see podman-generate-kube( | |||
|
|||
Note: HostPath volume types created by play kube will be given an SELinux private label (Z) | |||
|
|||
## OPTIONS: | |||
## FLAGS: |
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.
## FLAGS: | |
## FLAGS |
|
||
## DESCRIPTION | ||
Display the running processes of containers in a pod. The *format-descriptors* are ps (1) compatible AIX format descriptors but extended to print additional information, such as the seccomp mode or the effective capabilities of a given process. The descriptors can either be passed as separated arguments or as a single comma-separated argument. Note that you can also specify options and or flags of ps(1); in this case, Podman will fallback to executing ps with the specified arguments and flags in the container. | ||
Display the running processes of containers in a pod. The *format-descriptors* are ps (1) compatible AIX format descriptors but extended to print additional information, such as the seccomp mode or the effective capabilities of a given process. The descriptors can either be passed as separated arguments or as a single comma-separated argument. Note that you can also specify options and or options of ps(1); in this case, Podman will fallback to executing ps with the specified arguments and options in the container. |
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.
Display the running processes of containers in a pod. The *format-descriptors* are ps (1) compatible AIX format descriptors but extended to print additional information, such as the seccomp mode or the effective capabilities of a given process. The descriptors can either be passed as separated arguments or as a single comma-separated argument. Note that you can also specify options and or options of ps(1); in this case, Podman will fallback to executing ps with the specified arguments and options in the container. | |
Display the running processes of containers in a pod. The *format-descriptors* are ps (1) compatible AIX format descriptors but extended to print additional information, such as the seccomp mode or the effective capabilities of a given process. The descriptors can either be passed as separated arguments or as a single comma-separated argument. Note that you can specify options and/or additionally options of ps(1); in this case, Podman will fallback to executing ps with the specified arguments and options in the container. |
I suspect we would need to dig into how to override the whole help generation |
43ecd5c
to
49ca425
Compare
I fixed the help generation to use Options now. so back to original. I will need help from @edsantiago to get his tests to pass. test/system/015-help.bats still seems broken. |
BTW we definitely need the tests to run on this. This is not only CI Docs. |
At https://github.com/containers/podman/blob/master/cmd/podman/main.go#L69 you may need to add c.Command.DisableFlagsInUseLine = true |
One reason for [flags] is that Cobra automatically adds that string if it is missing from a help message. That is, if your command has flags-options-whatever, and you do not include the string "[flags]" in the Usage message, Cobra will helpfully add it (usually in the wrong place). I don't really care whether anyone uses flags or options, but I've had an exhausting day and am not going to be able to review this tonight or tomorrow. I'm sorry. I do hope my comment above is helpful at least. |
3b38fea
to
fe36ebf
Compare
@edsantiago I think I have removed all issues with Flags, now your test script is blowing up. Could you take a look at this PR versus your test script? |
Patch: diff --git a/cmd/podman/containers/list.go b/cmd/podman/containers/list.go
index daf03a51b..78a15559f 100644
--- a/cmd/podman/containers/list.go
+++ b/cmd/podman/containers/list.go
@@ -10,7 +10,7 @@ import (
var (
// podman container _list_
listCmd = &cobra.Command{
- Use: "list",
+ Use: "list [options]",
Aliases: []string{"ls"},
Args: validate.NoArgs,
Short: "List containers", That doesn't fix everything, though. |
Next patch (assumes that you fix the diff --git a/hack/xref-helpmsgs-manpages b/hack/xref-helpmsgs-manpages
index 7b617eed7..416d65182 100755
--- a/hack/xref-helpmsgs-manpages
+++ b/hack/xref-helpmsgs-manpages
@@ -228,14 +228,14 @@ sub podman_help {
# Usage: ...
# Available Commands:
# ....
- # Flags:
+ # Options:
# ....
#
# Start by identifying the section we're in...
if ($line =~ /^Available\s+(Commands):/) {
$section = lc $1;
}
- elsif ($line =~ /^(Flags):/) {
+ elsif ($line =~ /^(Options):/) {
$section = lc $1;
}
@@ -248,7 +248,7 @@ sub podman_help {
unless $subcommand eq 'help'; # 'help' not in man
}
}
- elsif ($section eq 'flags') {
+ elsif ($section eq 'options') {
# Handle '--foo' or '-f, --foo'
if ($line =~ /^\s{1,10}(--\S+)\s/) {
print "> podman @_ $1\n" if $debug;
@@ -320,7 +320,7 @@ sub podman_man {
}
}
- # Flags should always be of the form '**-f**' or '**--flag**',
+ # Options should always be of the form '**-f**' or '**--flag**',
# possibly separated by comma-space.
elsif ($section eq 'flags') {
# e.g. 'podman run --ip6', documented in man page, but nonexistent |
Here's one possible fix for setting diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index eed3968e5..d23230763 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -81,6 +81,7 @@ func init() {
)
rootFlags(rootCmd, registry.PodmanConfig())
+ rootCmd.SetUsageTemplate(usageTemplate)
}
func Execute() { Note that you do not want to set |
try this diff --git a/docs/remote-docs.sh b/docs/remote-docs.sh
index a9fda4696..67c731e75 100755
--- a/docs/remote-docs.sh
+++ b/docs/remote-docs.sh
@@ -78,7 +78,7 @@ function html_fn() {
# the command name but not its description.
function podman_commands() {
$PODMAN help "$@" |\
- awk '/^Available Commands:/{ok=1;next}/^Flags:/{ok=0}ok { print $1 }' |\
+ awk '/^Available Commands:/{ok=1;next}/^Options:/{ok=0}ok { print $1 }' |\
grep .
}
|
The second is easy, just an oversight: diff --git a/cmd/podman/containers/exists.go b/cmd/podman/containers/exists.go
index 1d79b684d..70b8af159 100644
--- a/cmd/podman/containers/exists.go
+++ b/cmd/podman/containers/exists.go
@@ -12,7 +12,7 @@ var (
containerExistsDescription = `If the named container exists in local storage, podman container exists exits with 0, otherwise the exit code will be 1.`
existsCommand = &cobra.Command{
- Use: "exists [flags] CONTAINER",
+ Use: "exists [options] CONTAINER",
Short: "Check if a container exists in local storage",
Long: containerExistsDescription,
Example: `podman container exists --external containerID The first is harder. Here is a side-by-side of old vs new:
IOW, the Best case would be to find a way to make that line |
This seems to have the desired (by me) effect: diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index d23230763..54c168bd2 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -38,7 +38,7 @@ Description:
// command should not use this.
const usageTemplate = `Usage:{{if (and .Runnable (not .HasAvailableSubCommands))}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
- {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
+ {{.CommandPath}}{{if .HasAvailableLocalFlags}} [options]{{end}} command{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
diff --git a/test/system/015-help.bats b/test/system/015-help.bats
index 22db8be8a..d6a8a80c9 100644
--- a/test/system/015-help.bats
+++ b/test/system/015-help.bats
@@ -3,7 +3,7 @@
# Tests based on 'podman help'
#
# Find all commands listed by 'podman --help'. Run each one, make sure it
-# provides its own --help output. If the usage message ends in '[command]',
+# provides its own --help output. If the usage message ends in 'command',
# treat it as a subcommand, and recurse into its own list of sub-subcommands.
#
# Any usage message that ends in '[options]' is interpreted as a command
@@ -45,8 +45,8 @@ function check_help() {
# has no ' [options]'
is "$usage " " $command_string .*" "Usage string matches command"
- # If usage ends in '[command]', recurse into subcommands
- if expr "$usage" : '.*\[command\]$' >/dev/null; then
+ # If usage ends in 'command', recurse into subcommands
+ if expr "$usage" : '.*command$' >/dev/null; then
found[subcommands]=1
check_help "$@" $cmd
continue
I don't know if others will find that 'command' (no brackets) desirable; nor do I know what other side effects it might have. Also, I think you lost one of the changes I specified above. You'll need to apply this to get the man-page xref to pass: diff --git a/hack/xref-helpmsgs-manpages b/hack/xref-helpmsgs-manpages
index a7063259f..416d65182 100755
--- a/hack/xref-helpmsgs-manpages
+++ b/hack/xref-helpmsgs-manpages
@@ -248,7 +248,7 @@ sub podman_help {
unless $subcommand eq 'help'; # 'help' not in man
}
}
- elsif ($section eq 'flags') {
+ elsif ($section eq 'options') {
# Handle '--foo' or '-f, --foo'
if ($line =~ /^\s{1,10}(--\S+)\s/) {
print "> podman @_ $1\n" if $debug; |
I think you missed this one #8034 (comment) |
While you're at it would you mind diff --git a/completions/zsh/_podman b/completions/zsh/_podman
index 067eebbbb..80dc5125d 100644
--- a/completions/zsh/_podman
+++ b/completions/zsh/_podman
@@ -206,7 +206,7 @@ _set_up_podman_args() {
typeset -ga _podman_args=()
# E.g. 'podman exec [flags] CONTAINER [...' -> 'CONTAINER [....'
- local usage_rhs=$(expr "$_podman_usage" : ".*\[flags\] \+\(.*\)")
+ local usage_rhs=$(expr "$_podman_usage" : ".*\[options\] \+\(.*\)")
# e.g. podman pod ps which takes no further args
if [ -z "$usage_rhs" ]; then |
Want to have man pages match commands, since we have lots of printed man pages with using Options, we will change the command line to use Options in --help. Signed-off-by: Daniel J Walsh <[email protected]>
Error was:
Treating as a flake. Restarted. |
/lgtm @containers/podman-maintainers PTAL, let's get this in before some breaking change merges and causes conflicts |
LGTM |
Somewhere in the CIv2 migration we lost the man page vs --help cross-checker. Add it back, by adding it into the man-page-check Makefile target; this is part of 'make validate', which is run in CI even on CI:DOCS PRs. As happens when CI doesn't run, things broke. Man pages got out of sync with --help. This PR: 1) Fixes hack/xref-helpmsgs-manpages to deal with the new "Options" (instead of "Flags") form of podman help. containers#8034 did part of that, but one of my review comments was accidentally left out. 2) Fixes hack/xref-helpmsgs-manpages to deal with the new option syntax in man pages, post- containers#8292, in which each option is preceded by four hashes so as to make them HTML <h4> elements with named anchors. 3) Fixes man pages that containers#8292 accidentally missed. 4) Adds man page entries for two flags that got added to podman but not documented (pod create --network-alias, play kube --log-driver) Fixes: containers#8296 Signed-off-by: Ed Santiago <[email protected]>
Want to have man pages match commands, since we have lots of printed
man pages with using Options, we will change the command line to use
Options in --help.
Signed-off-by: Daniel J Walsh [email protected]