Use reflect-compatible struct tags in examples

This commit is contained in:
Nate Parsons
2021-11-22 19:13:08 -08:00
committed by Alec Thomas
parent 79f896f0c0
commit f00d33b57c
3 changed files with 46 additions and 51 deletions
+4 -4
View File
@@ -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.
+1 -6
View File
@@ -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()