Use reflect-compatible struct tags in examples
This commit is contained in:
committed by
Alec Thomas
parent
79f896f0c0
commit
f00d33b57c
+41
-41
@@ -33,47 +33,47 @@ func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error {
|
||||
type CLI struct {
|
||||
Globals
|
||||
|
||||
Attach AttachCmd `cmd help:"Attach local standard input, output, and error streams to a running container"`
|
||||
Build BuildCmd `cmd help:"Build an image from a Dockerfile"`
|
||||
Commit CommitCmd `cmd help:"Create a new image from a container's changes"`
|
||||
Cp CpCmd `cmd help:"Copy files/folders between a container and the local filesystem"`
|
||||
Create CreateCmd `cmd help:"Create a new container"`
|
||||
Deploy DeployCmd `cmd help:"Deploy a new stack or update an existing stack"`
|
||||
Diff DiffCmd `cmd help:"Inspect changes to files or directories on a container's filesystem"`
|
||||
Events EventsCmd `cmd help:"Get real time events from the server"`
|
||||
Exec ExecCmd `cmd help:"Run a command in a running container"`
|
||||
Export ExportCmd `cmd help:"Export a container's filesystem as a tar archive"`
|
||||
History HistoryCmd `cmd help:"Show the history of an image"`
|
||||
Images ImagesCmd `cmd help:"List images"`
|
||||
Import ImportCmd `cmd help:"Import the contents from a tarball to create a filesystem image"`
|
||||
Info InfoCmd `cmd help:"Display system-wide information"`
|
||||
Inspect InspectCmd `cmd help:"Return low-level information on Docker objects"`
|
||||
Kill KillCmd `cmd help:"Kill one or more running containers"`
|
||||
Load LoadCmd `cmd help:"Load an image from a tar archive or STDIN"`
|
||||
Login LoginCmd `cmd help:"Log in to a Docker registry"`
|
||||
Logout LogoutCmd `cmd help:"Log out from a Docker registry"`
|
||||
Logs LogsCmd `cmd help:"Fetch the logs of a container"`
|
||||
Pause PauseCmd `cmd help:"Pause all processes within one or more containers"`
|
||||
Port PortCmd `cmd help:"List port mappings or a specific mapping for the container"`
|
||||
Ps PsCmd `cmd help:"List containers"`
|
||||
Pull PullCmd `cmd help:"Pull an image or a repository from a registry"`
|
||||
Push PushCmd `cmd help:"Push an image or a repository to a registry"`
|
||||
Rename RenameCmd `cmd help:"Rename a container"`
|
||||
Restart RestartCmd `cmd help:"Restart one or more containers"`
|
||||
Rm RmCmd `cmd help:"Remove one or more containers"`
|
||||
Rmi RmiCmd `cmd help:"Remove one or more images"`
|
||||
Run RunCmd `cmd help:"Run a command in a new container"`
|
||||
Save SaveCmd `cmd help:"Save one or more images to a tar archive (streamed to STDOUT by default)"`
|
||||
Search SearchCmd `cmd help:"Search the Docker Hub for images"`
|
||||
Start StartCmd `cmd help:"Start one or more stopped containers"`
|
||||
Stats StatsCmd `cmd help:"Display a live stream of container(s) resource usage statistics"`
|
||||
Stop StopCmd `cmd help:"Stop one or more running containers"`
|
||||
Tag TagCmd `cmd help:"Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE"`
|
||||
Top TopCmd `cmd help:"Display the running processes of a container"`
|
||||
Unpause UnpauseCmd `cmd help:"Unpause all processes within one or more containers"`
|
||||
Update UpdateCmd `cmd help:"Update configuration of one or more containers"`
|
||||
Version VersionCmd `cmd help:"Show the Docker version information"`
|
||||
Wait WaitCmd `cmd help:"Block until one or more containers stop, then print their exit codes"`
|
||||
Attach AttachCmd `cmd:"" help:"Attach local standard input, output, and error streams to a running container"`
|
||||
Build BuildCmd `cmd:"" help:"Build an image from a Dockerfile"`
|
||||
Commit CommitCmd `cmd:"" help:"Create a new image from a container's changes"`
|
||||
Cp CpCmd `cmd:"" help:"Copy files/folders between a container and the local filesystem"`
|
||||
Create CreateCmd `cmd:"" help:"Create a new container"`
|
||||
Deploy DeployCmd `cmd:"" help:"Deploy a new stack or update an existing stack"`
|
||||
Diff DiffCmd `cmd:"" help:"Inspect changes to files or directories on a container's filesystem"`
|
||||
Events EventsCmd `cmd:"" help:"Get real time events from the server"`
|
||||
Exec ExecCmd `cmd:"" help:"Run a command in a running container"`
|
||||
Export ExportCmd `cmd:"" help:"Export a container's filesystem as a tar archive"`
|
||||
History HistoryCmd `cmd:"" help:"Show the history of an image"`
|
||||
Images ImagesCmd `cmd:"" help:"List images"`
|
||||
Import ImportCmd `cmd:"" help:"Import the contents from a tarball to create a filesystem image"`
|
||||
Info InfoCmd `cmd:"" help:"Display system-wide information"`
|
||||
Inspect InspectCmd `cmd:"" help:"Return low-level information on Docker objects"`
|
||||
Kill KillCmd `cmd:"" help:"Kill one or more running containers"`
|
||||
Load LoadCmd `cmd:"" help:"Load an image from a tar archive or STDIN"`
|
||||
Login LoginCmd `cmd:"" help:"Log in to a Docker registry"`
|
||||
Logout LogoutCmd `cmd:"" help:"Log out from a Docker registry"`
|
||||
Logs LogsCmd `cmd:"" help:"Fetch the logs of a container"`
|
||||
Pause PauseCmd `cmd:"" help:"Pause all processes within one or more containers"`
|
||||
Port PortCmd `cmd:"" help:"List port mappings or a specific mapping for the container"`
|
||||
Ps PsCmd `cmd:"" help:"List containers"`
|
||||
Pull PullCmd `cmd:"" help:"Pull an image or a repository from a registry"`
|
||||
Push PushCmd `cmd:"" help:"Push an image or a repository to a registry"`
|
||||
Rename RenameCmd `cmd:"" help:"Rename a container"`
|
||||
Restart RestartCmd `cmd:"" help:"Restart one or more containers"`
|
||||
Rm RmCmd `cmd:"" help:"Remove one or more containers"`
|
||||
Rmi RmiCmd `cmd:"" help:"Remove one or more images"`
|
||||
Run RunCmd `cmd:"" help:"Run a command in a new container"`
|
||||
Save SaveCmd `cmd:"" help:"Save one or more images to a tar archive (streamed to STDOUT by default)"`
|
||||
Search SearchCmd `cmd:"" help:"Search the Docker Hub for images"`
|
||||
Start StartCmd `cmd:"" help:"Start one or more stopped containers"`
|
||||
Stats StatsCmd `cmd:"" help:"Display a live stream of container(s) resource usage statistics"`
|
||||
Stop StopCmd `cmd:"" help:"Stop one or more running containers"`
|
||||
Tag TagCmd `cmd:"" help:"Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE"`
|
||||
Top TopCmd `cmd:"" help:"Display the running processes of a container"`
|
||||
Unpause UnpauseCmd `cmd:"" help:"Unpause all processes within one or more containers"`
|
||||
Update UpdateCmd `cmd:"" help:"Update configuration of one or more containers"`
|
||||
Version VersionCmd `cmd:"" help:"Show the Docker version information"`
|
||||
Wait WaitCmd `cmd:"" help:"Block until one or more containers stop, then print their exit codes"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -12,10 +12,10 @@ var _ = kong.Must(&grammar{})
|
||||
|
||||
// Server interface.
|
||||
type grammar struct {
|
||||
Help helpCmd `cmd help:"Show help."`
|
||||
Question helpCmd `cmd hidden name:"?" help:"Show help."`
|
||||
Help helpCmd `cmd:"" help:"Show help."`
|
||||
Question helpCmd `cmd:"" hidden:"" name:"?" help:"Show help."`
|
||||
|
||||
Status statusCmd `cmd help:"Show server status."`
|
||||
Status statusCmd `cmd:"" help:"Show server status."`
|
||||
}
|
||||
|
||||
type statusCmd struct {
|
||||
@@ -28,7 +28,7 @@ func (s *statusCmd) Run(ctx *kong.Context) error {
|
||||
}
|
||||
|
||||
type helpCmd struct {
|
||||
Command []string `arg optional help:"Show help on command."`
|
||||
Command []string `arg:"" optional:"" help:"Show help on command."`
|
||||
}
|
||||
|
||||
// Run shows help.
|
||||
|
||||
@@ -18,17 +18,12 @@ import (
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
type context struct {
|
||||
kong *kong.Context
|
||||
rl *readline.Instance
|
||||
}
|
||||
|
||||
// Handle a single SSH interactive connection.
|
||||
func handle(log *log.Logger, s ssh.Session) error {
|
||||
log.Printf("New SSH")
|
||||
sshPty, _, isPty := s.Pty()
|
||||
if !isPty {
|
||||
return errors.New("No PTY requested")
|
||||
return errors.New("no PTY requested")
|
||||
}
|
||||
log.Printf("Using TERM=%s width=%d height=%d", sshPty.Term, sshPty.Window.Width, sshPty.Window.Height)
|
||||
cpty, tty, err := pty.Open()
|
||||
|
||||
Reference in New Issue
Block a user