Files
Jamie LiuandgVisor bot e3d698f392 runsc: implement -h and -help flags
This is consistent with runc; see containers/podman#27528.

Before this change:

```
$ ./runsc --help
Usage of ./runsc:
$ echo $?
2
$ ./runsc ps --help
<container-id> [ps options]  -format="table": output format. Select one of: table or json (default: table)
$ echo $?
2
```

After this change:

```
$ ./runsc --help
Usage: runsc <flags> <subcommand> <subcommand args>

runsc is the gVisor container runtime.

Functionality is provided by subcommands. For help with a specific subcommand,
use "runsc help <subcommand>".

Subcommands:
        checkpoint       checkpoint current state of container (experimental)
        create           create a secure container
        delete           delete resources held by a container
        do               Simplistic way to execute a command inside the sandbox. It's to be used for testing only.
        events           display container events such as OOM notifications, cpu, memory, and IO usage statistics
        exec             execute new process inside the container
        flags            describe all known top-level flags
        help             Print help documentation.
        kill             sends a signal to the container
        list             list containers started by runsc with the given root
        pause            pause suspends all processes in a container
        port-forward     port forward to a secure container
        ps               ps displays the processes running inside a container
        restore          restore a saved state of container (experimental)
        resume           Resume unpauses a paused container
        run              create and run a secure container
        spec             create a new OCI bundle specification file
        start            start a secure container
        state            get the state of a container
        tar              creates tar archives from container filesystems
        wait             wait on a process inside a container

Subcommands for debug:
        debug            shows a variety of debug information
        read-control     read a cgroups control value inside the container
        statefile        shows information about a statefile
        symbolize        Convert synthetic instruction pointers from kcov into positions in the runsc source code. Only used when Go coverage is enabled.
        usage            Usage shows application memory usage across various categories in bytes.
        write-control    write a cgroups control value inside the container

Subcommands for helpers:
        cpu-features     list CPU features supported on current machine
        install          adds a runtime to docker daemon configuration
        mitigate         mitigate mitigates the underlying system against side channel attacks
        nvproxy          shows information about nvproxy support
        trace            manages trace sessions for a given sandbox
        uninstall        removes a runtime from docker daemon configuration

Subcommands for internal use only:
        boot             launch a sandbox process
        gofer            launch a gofer process that proxies access to container files
        umount           umount the specified directory lazily when one byte is read from sync-fd

Subcommands for metrics:
        export-metrics   export metric data for the sandbox
        metric-metadata  export metric metadata of metrics registered in this build, in text proto format
        metric-server    implements Prometheus metrics HTTP endpoint

Additional help topics (Use "runsc help <topic>" to see help on the topic):
        platforms        Print a list of available platforms.
        syscalls         Print compatibility information for syscalls.

Use "runsc flags" for a list of top-level flags
$ echo $?
0
$ ./runsc ps --help
<container-id> [ps options]  -format="table": output format. Select one of: table or json (default: table)
  -h=false: equivalent to the 'help' flag
  -help=false: show this message and exit
$ echo $?
0
```

PiperOrigin-RevId: 837251082
2025-11-26 14:08:18 -08:00

57 lines
1.5 KiB
Go

// Copyright 2019 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !false
// +build !false
// Package flag wraps flag primitives.
package flag
import (
"flag"
)
// FlagSet is an alias for flag.FlagSet.
type FlagSet = flag.FlagSet
// Flag is an alias for flag.Flag.
type Flag = flag.Flag
// Aliases for flag functions.
var (
Bool = flag.Bool
BoolVar = flag.BoolVar
CommandLine = flag.CommandLine
Duration = flag.Duration
Float64 = flag.Float64
Int = flag.Int
Int64 = flag.Int64
Lookup = flag.Lookup
NewFlagSet = flag.NewFlagSet
Parse = flag.Parse
String = flag.String
StringVar = flag.StringVar
Uint = flag.Uint
Uint64 = flag.Uint64
Var = flag.Var
)
// ContinueOnError is an alias for flag.ContinueOnError.
const ContinueOnError = flag.ContinueOnError
// Get returns the flag's underlying object.
func Get(v flag.Value) any {
return v.(flag.Getter).Get()
}