Skip to content
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

fix: make command usage more readable in doc #549

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (c *Cli) AddCommand(parent, child Command) {
// make command error not return command usage and error
childCmd.SilenceUsage = true
childCmd.SilenceErrors = true
childCmd.DisableFlagsInUseLine = true

childCmd.PreRun = func(cmd *cobra.Command, args []string) {
c.NewAPIClient()
Expand Down
2 changes: 1 addition & 1 deletion cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type CreateCommand struct {
func (cc *CreateCommand) Init(c *Cli) {
cc.cli = c
cc.cmd = &cobra.Command{
Use: "create [image]",
Use: "create [OPTIONS] IMAGE [ARG...]",
Short: "Create a new container with specified image",
Long: createDescription,
Args: cobra.MinimumNArgs(1),
Expand Down
2 changes: 1 addition & 1 deletion cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ExecCommand struct {
func (e *ExecCommand) Init(c *Cli) {
e.cli = c
e.cmd = &cobra.Command{
Use: "exec [container]",
Use: "exec [OPTIONS] CONTAINER COMMAND [ARG...]",
Short: "Exec a process in a running container",
Long: execDescription,
Args: cobra.MinimumNArgs(2),
Expand Down
2 changes: 1 addition & 1 deletion cli/generate_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type GenDocCommand struct {
func (g *GenDocCommand) Init(c *Cli) {
g.cli = c
g.cmd = &cobra.Command{
Use: "gen-doc [container]",
Use: "gen-doc",
Short: "Generate docs",
Long: genDocDescription,
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion cli/image_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ImageInspectCommand struct {
func (i *ImageInspectCommand) Init(c *Cli) {
i.cli = c
i.cmd = &cobra.Command{
Use: "inspect image",
Use: "inspect [OPTIONS] IMAGE",
Short: "Display detailed information on one image",
Long: imageInspectDescription,
Args: cobra.ExactArgs(1),
Expand Down
2 changes: 1 addition & 1 deletion cli/image_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ImagesCommand struct {
func (i *ImagesCommand) Init(c *Cli) {
i.cli = c
i.cmd = &cobra.Command{
Use: "images",
Use: "images [OPTIONS]",
Short: "List all images",
Long: imagesDescription,
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion cli/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type InspectCommand struct {
func (p *InspectCommand) Init(c *Cli) {
p.cli = c
p.cmd = &cobra.Command{
Use: "inspect [container]",
Use: "inspect CONTAINER",
Short: "Get the detailed information of container",
Long: inspectDescription,
Args: cobra.ExactArgs(1),
Expand Down
4 changes: 2 additions & 2 deletions cli/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ func (n *NetworkCreateCommand) Init(c *Cli) {
n.cli = c

n.cmd = &cobra.Command{
Use: "create [name]",
Use: "create [OPTIONS] [NAME]",
Short: "Create a pouch network",
Long: networkCreateDescription,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return n.runNetworkCreate(args)
},
Example: networkCreateExample(),
Args: cobra.MaximumNArgs(1),
}

n.addFlags()
Expand Down
2 changes: 1 addition & 1 deletion cli/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type PauseCommand struct {
func (p *PauseCommand) Init(c *Cli) {
p.cli = c
p.cmd = &cobra.Command{
Use: "pause [container]",
Use: "pause CONTAINER",
Short: "Pause a running container",
Long: pauseDescription,
Args: cobra.ExactArgs(1),
Expand Down
2 changes: 1 addition & 1 deletion cli/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type PsCommand struct {
func (p *PsCommand) Init(c *Cli) {
p.cli = c
p.cmd = &cobra.Command{
Use: "ps",
Use: "ps [OPTIONS]",
Short: "List containers",
Long: psDescription,
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p *PullCommand) Init(c *Cli) {
p.cli = c

p.cmd = &cobra.Command{
Use: "pull [image]",
Use: "pull IMAGE",
Short: "Pull an image from registry",
Long: pullDescription,
Args: cobra.MinimumNArgs(1),
Expand Down
6 changes: 2 additions & 4 deletions cli/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (rc *RenameCommand) Init(c *Cli) {
rc.cli = c

rc.cmd = &cobra.Command{
Use: "rename [container] [newName]",
Use: "rename CONTAINER NEWNAME",
Short: "Rename a container with newName",
Long: renameDescription,
Args: cobra.ExactArgs(2),
Expand All @@ -36,9 +36,7 @@ func (rc *RenameCommand) runRename(args []string) error {
container := args[0]
newName := args[1]

err := apiClient.ContainerRename(container, newName)

return err
return apiClient.ContainerRename(container, newName)
}

// renameExample shows examples in rename command, and is used in auto-generated cli docs.
Expand Down
2 changes: 1 addition & 1 deletion cli/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type RmCommand struct {
func (r *RmCommand) Init(c *Cli) {
r.cli = c
r.cmd = &cobra.Command{
Use: "rm container",
Use: "rm [OPTIONS] CONTAINER [CONTAINER...]",
Short: "Remove one or more containers",
Long: rmDescription,
Args: cobra.MinimumNArgs(1),
Expand Down
2 changes: 1 addition & 1 deletion cli/rmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type RmiCommand struct {
func (rmi *RmiCommand) Init(c *Cli) {
rmi.cli = c
rmi.cmd = &cobra.Command{
Use: "rmi image ",
Use: "rmi [OPTIONS] IMAGE [IMAGE...]",
Short: "Remove one or more images by reference",
Long: rmiDescription,
Args: cobra.MinimumNArgs(1),
Expand Down
2 changes: 1 addition & 1 deletion cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type RunCommand struct {
func (rc *RunCommand) Init(c *Cli) {
rc.cli = c
rc.cmd = &cobra.Command{
Use: "run a container",
Use: "run [OPTIONS] IMAGE [ARG...]",
Short: "Create a new container and start it",
Long: runDescription,
Args: cobra.MinimumNArgs(1),
Expand Down
4 changes: 2 additions & 2 deletions cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type StartCommand struct {
func (s *StartCommand) Init(c *Cli) {
s.cli = c
s.cmd = &cobra.Command{
Use: "start [container]",
Use: "start [OPTIONS] CONTAINER",
Short: "Start a created or stopped container",
Long: startDescription,
Args: cobra.MinimumNArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return s.runStart(args)
},
Expand Down
4 changes: 2 additions & 2 deletions cli/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ type StopCommand struct {
func (s *StopCommand) Init(c *Cli) {
s.cli = c
s.cmd = &cobra.Command{
Use: "stop [container]",
Use: "stop [OPTIONS] CONTAINER",
Short: "Stop a running container",
Long: stopDescription,
Args: cobra.MinimumNArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return s.runStop(args)
},
Expand Down
2 changes: 1 addition & 1 deletion cli/unpause.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type UnpauseCommand struct {
func (p *UnpauseCommand) Init(c *Cli) {
p.cli = c
p.cmd = &cobra.Command{
Use: "unpause [container]",
Use: "unpause CONTAINER",
Short: "Unpause a paused container",
Long: unpauseDescription,
Args: cobra.ExactArgs(1),
Expand Down
4 changes: 2 additions & 2 deletions cli/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (v *VolumeCreateCommand) Init(c *Cli) {
v.cli = c

v.cmd = &cobra.Command{
Use: "create [args]",
Use: "create [OPTIONS]",
Short: "Create a volume",
Long: volumeCreateDescription,
Args: cobra.NoArgs,
Expand Down Expand Up @@ -164,7 +164,7 @@ type VolumeRemoveCommand struct {
func (v *VolumeRemoveCommand) Init(c *Cli) {
v.cli = c
v.cmd = &cobra.Command{
Use: "remove <name>",
Use: "remove VOLUME",
Aliases: []string{"rm"},
Short: "Remove volume",
Long: volumeRmDescription,
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pouch is a client side tool pouch to interact with daemon side process pouchd. F
* [pouch inspect](pouch_inspect.md) - Get the detailed information of container
* [pouch network](pouch_network.md) - Manage pouch networks
* [pouch pause](pouch_pause.md) - Pause a running container
* [pouch ps](pouch_ps.md) - List all containers
* [pouch ps](pouch_ps.md) - List containers
* [pouch pull](pouch_pull.md) - Pull an image from registry
* [pouch rename](pouch_rename.md) - Rename a container with newName
* [pouch rm](pouch_rm.md) - Remove one or more containers
Expand Down
25 changes: 19 additions & 6 deletions docs/commandline/pouch_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a new container with specified image
Create a static container object in Pouchd. When creating, all configuration user input will be stored in memory store of Pouchd. This is useful when you wish to create a container configuration ahead of time so that Pouchd will preserve the resource in advance. The container you created is ready to start when you need it.

```
pouch create [image] [flags]
pouch create [OPTIONS] IMAGE [ARG...]
```

### Examples
Expand All @@ -20,11 +20,24 @@ container ID: e1d541722d68dc5d133cca9e7bd8fd9338603e1763096c8e853522b60d11f7b9,
### Options

```
-h, --help help for create
--name string Specify name of container
--runtime string Specify oci runtime
-t, --tty Allocate a tty device
-v, --volume strings Bind mount volumes to container
--cpu-share int CPU shares
--cpuset-cpus string CPUs in cpuset
--cpuset-mems string MEMs in cpuset
--device strings Add a host device to the container
--enableLxcfs Enable lxcfs
--entrypoint string Overwrite the default entrypoint
-e, --env strings Set environment variables for container
-h, --help help for create
--hostname string Set container's hostname
-l, --label strings Set label for a container
-m, --memory string Container memory limit
--memory-swap string Container swap limit
--memory-wappiness int Container memory swappiness [0, 100] (default -1)
--name string Specify name of container
--runtime string Specify oci runtime
-t, --tty Allocate a tty device
-v, --volume strings Bind mount volumes to container
-w, --workdir string Set the working directory in a container
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Exec a process in a running container
Exec a process in a running container

```
pouch exec [container] [flags]
pouch exec [OPTIONS] CONTAINER COMMAND [ARG...]
```

### Options
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_gen-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Generate docs
Generate docs

```
pouch gen-doc [container] [flags]
pouch gen-doc
```

### Options
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_image_inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Display detailed information on one image
Return detailed information on Pouch image

```
pouch image inspect image [flags]
pouch image inspect [OPTIONS] IMAGE
```

### Examples
Expand Down
4 changes: 2 additions & 2 deletions docs/commandline/pouch_images.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ List all images
List all images in Pouchd.This is useful when you wish to have a look at images and Pouchd will show all local images with their NAME and SIZE.All local images will be shown in a table format you can use.

```
pouch images [flags]
pouch images [OPTIONS]
```

### Examples

```
$ pouch images ls
$ pouch images
IMAGE ID IMAGE NAME SIZE
bbc3a0323522 docker.io/library/busybox:latest 703.14 KB
b81f317384d7 docker.io/library/nginx:latest 42.39 MB
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Get the detailed information of container
Return detailed information on Pouch container

```
pouch inspect [container] [flags]
pouch inspect CONTAINER
```

### Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_network_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a pouch network
Create a network in pouchd. It must specify network's name and driver. You can use 'network driver' to get drivers that pouch support.

```
pouch network create [name] [flags]
pouch network create [OPTIONS] [NAME]
```

### Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_pause.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pause a running container
Pause a running container object in Pouchd. when pausing, the container will pause its running but hold all the relevant resource.This is useful when you wish to pause a container for a while and to restore the running status later.The container you paused will pause without being terminated.

```
pouch pause [container] [flags]
pouch pause CONTAINER
```

### Examples
Expand Down
31 changes: 24 additions & 7 deletions docs/commandline/pouch_ps.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
## pouch ps

List all containers
List containers

### Synopsis


List Containers with container name, ID, status, image reference, runtime and creation time.
List Containers with container name, ID, status, creation time, image reference and runtime.

```
pouch ps [flags]
pouch ps [OPTIONS]
```

### Examples

```
$ pouch ps
Name ID Status Image Runtime Created
1dad17 1dad17 stopped docker.io/library/busybox:latest runv 1 hour ago
505571 505571 stopped docker.io/library/busybox:latest runc 1 hour ago
Name ID Status Created Image Runtime
2 e42c68 Up 15 minutes 16 minutes ago docker.io/library/busybox:latest runc
1 a8c2ea Up 16 minutes 17 minutes ago docker.io/library/busybox:latest runc

$ pouch ps -a
Name ID Status Created Image Runtime
3 faf132 created 16 seconds ago docker.io/library/busybox:latest runc
2 e42c68 Up 16 minutes 16 minutes ago docker.io/library/busybox:latest runc
1 a8c2ea Up 17 minutes 18 minutes ago docker.io/library/busybox:latest runc

$ pouch ps -q
e42c68
a8c2ea

$ pouch ps -a -q
faf132
e42c68
a8c2ea

```

### Options

```
-h, --help help for ps
-a, --all Show all containers (default shows just running)
-h, --help help for ps
-q, --quiet Only show numeric IDs
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_pull.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pull an image from registry
Pull an image or a repository from a registry. Most of your images will be created on top of a base image from the registry. So, you can pull and try prebuilt images contained by registry without needing to define and configure your own.

```
pouch pull [image] [flags]
pouch pull IMAGE
```

### Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline/pouch_rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Rename a container with newName
Rename a container object in Pouchd. You can change the name of one container identified by its name or ID. The container you renamed is ready to be used by its new name.

```
pouch rename [container] [newName] [flags]
pouch rename CONTAINER NEWNAME
```

### Examples
Expand Down
Loading