cli: Workaround for ps's argument
Currently, ps command can not support argument: (But following usage is in manual) | # ./runc ps 123 -ef | Incorrect Usage. | | NAME: | runc ps - ps displays the processes running inside a container | | USAGE: | runc ps [command options] <container-id> [ps options] | | OPTIONS: | --format value, -f value select one of: table or json | | flag provided but not defined: -ef | # Instead of using odd command like: | # ./runc ps -- 123 -ef We can make it seems little better: | # ./runc ps 123 -- -ef | UID PID PPID C STIME TTY TIME CMD | root 29046 29038 0 11:18 pts/2 00:00:00 sh | # This patch also fixed manual which can not working in current code. Closes #788 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
This commit is contained in:
parent
7221e38782
commit
f5a95fa244
|
@ -2,7 +2,7 @@
|
|||
runc ps - ps displays the processes running inside a container
|
||||
|
||||
# SYNOPSIS
|
||||
runc ps [command options] <container-id> [ps options]
|
||||
runc ps [command options] <container-id> [-- ps options]
|
||||
|
||||
# OPTIONS
|
||||
--format value, -f value select one of: table(default) or json
|
||||
|
|
5
ps.go
5
ps.go
|
@ -16,7 +16,7 @@ import (
|
|||
var psCommand = cli.Command{
|
||||
Name: "ps",
|
||||
Usage: "ps displays the processes running inside a container",
|
||||
ArgsUsage: `<container-id> [ps options]`,
|
||||
ArgsUsage: `<container-id> [-- ps options]`,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "format, f",
|
||||
|
@ -43,6 +43,9 @@ var psCommand = cli.Command{
|
|||
}
|
||||
|
||||
psArgs := context.Args().Get(1)
|
||||
if psArgs == "--" {
|
||||
psArgs = context.Args().Get(2)
|
||||
}
|
||||
if psArgs == "" {
|
||||
psArgs = "-ef"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue