Skip to content

Commit a9a093f

Browse files
vax-rgvisor-bot
authored andcommitted
runsc: Fix newline for cmd usage display
## Summary Originally, some of the commands' usage display didn't achieved to show newline, while some of them does, which are more user-friendly, and won't confuse the message if there're more which should be in the nextline. Fix this issue by returning usage string with a newline. ## Tests Before the change some commands display their usage like the following, for example `runsc start` ``` vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ runsc start start <container id> - start a secure container.vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ ``` Or `runsc wait` ``` vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ runsc wait wait [flags] <container id> -checkpoint wait for the next checkpoint to complete -pid int select a PID in the container's PID namespace to wait on instead of the container's root process (default -1) -rootpid int select a PID in the sandbox root PID namespace to wait on instead of the container's root process (default -1) ``` We can see in the case of `runsc wait`, the flag `-checkpoint` is expected to be shown in a way which is aligned with other flags, like ``` vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ runsc wait wait [flags] <container id> -checkpoint wait for the next checkpoint to complete -pid int select a PID in the container's PID namespace to wait on instead of the container's root process (default -1) -rootpid int select a PID in the sandbox root PID namespace to wait on instead of the container's root process (default -1) ``` After the change , we can see those commands with this issue are being fixed. ``` vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ runsc start start <container id> - start a secure container. vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ ``` ``` vax-r@vaxr-ASUSPRO-D840MB-M840MB:~/gvisor$ runsc wait wait [flags] <container id> -checkpoint wait for the next checkpoint to complete -pid int select a PID in the container's PID namespace to wait on instead of the container's root process (default -1) -rootpid int select a PID in the sandbox root PID namespace to wait on instead of the container's root process (default -1) ``` FUTURE_COPYBARA_INTEGRATE_REVIEW=#11324 from vax-r:fix_usage_display 83f9f18 PiperOrigin-RevId: 710756149
1 parent 6c5bc5e commit a9a093f

29 files changed

+30
-48
lines changed

runsc/cmd/boot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (*Boot) Synopsis() string {
201201

202202
// Usage implements subcommands.Command.Usage.
203203
func (*Boot) Usage() string {
204-
return `boot [flags] <container id>`
204+
return "boot [flags] <container id>\n"
205205
}
206206

207207
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/checkpoint.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ func (*Checkpoint) Synopsis() string {
5555

5656
// Usage implements subcommands.Command.Usage.
5757
func (*Checkpoint) Usage() string {
58-
return `checkpoint [flags] <container id> - save current state of container.
59-
`
58+
return "checkpoint [flags] <container id> - save current state of container.\n"
6059
}
6160

6261
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/create.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ func (*Create) Synopsis() string {
6262

6363
// Usage implements subcommands.Command.Usage.
6464
func (*Create) Usage() string {
65-
return `create [flags] <container id> - create a secure container
66-
`
65+
return "create [flags] <container id> - create a secure container\n"
6766
}
6867

6968
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (*Debug) Synopsis() string {
6464

6565
// Usage implements subcommands.Command.
6666
func (*Debug) Usage() string {
67-
return `debug [flags] <container id>`
67+
return "debug [flags] <container id>\n"
6868
}
6969

7070
// SetFlags implements subcommands.Command.

runsc/cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (*Delete) Synopsis() string {
4545

4646
// Usage implements subcommands.Command.Usage.
4747
func (*Delete) Usage() string {
48-
return `delete [flags] <container ids>`
48+
return "delete [flags] <container ids>\n"
4949
}
5050

5151
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/gofer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (g *Gofer) Synopsis() string {
112112

113113
// Usage implements subcommands.Command.
114114
func (*Gofer) Usage() string {
115-
return `gofer [flags]`
115+
return "gofer [flags]\n"
116116
}
117117

118118
// SetFlags implements subcommands.Command.

runsc/cmd/install.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ func (*Install) Synopsis() string {
5252

5353
// Usage implements subcommands.Command.Usage.
5454
func (*Install) Usage() string {
55-
return `install [--runtime=<name>] [flags] [-- [args...]] -- if provided, args are passed to the runtime
56-
`
55+
return "install [--runtime=<name>] [flags] [-- [args...]] -- if provided, args are passed to the runtime\n"
5756
}
5857

5958
// SetFlags implements subcommands.Command.SetFlags.
@@ -212,8 +211,7 @@ func (*Uninstall) Synopsis() string {
212211

213212
// Usage implements subcommands.Command.Usage.
214213
func (*Uninstall) Usage() string {
215-
return `uninstall [flags] <name>
216-
`
214+
return "uninstall [flags] <name>\n"
217215
}
218216

219217
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/kill.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (*Kill) Synopsis() string {
4646

4747
// Usage implements subcommands.Command.Usage.
4848
func (*Kill) Usage() string {
49-
return `kill <container id> [signal]`
49+
return "kill <container id> [signal]\n"
5050
}
5151

5252
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (*List) Synopsis() string {
5151

5252
// Usage implements subcommands.Command.Usage.
5353
func (*List) Usage() string {
54-
return `list [flags]`
54+
return "list [flags]\n"
5555
}
5656

5757
// SetFlags implements subcommands.Command.SetFlags.

runsc/cmd/metric_export.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ func (*MetricExport) Synopsis() string {
4747

4848
// Usage implements subcommands.Command.Usage.
4949
func (*MetricExport) Usage() string {
50-
return `export-metrics [-exporter-prefix=<runsc_>] <container id> - prints sandbox metric data in Prometheus metric format
51-
`
50+
return "export-metrics [-exporter-prefix=<runsc_>] <container id> - prints sandbox metric data in Prometheus metric format\n"
5251
}
5352

5453
// SetFlags implements subcommands.Command.SetFlags.

0 commit comments

Comments
 (0)