mirror of https://github.com/docker/cli.git
cli/command/container: add completion for --stop-signal
With this patch:
docker run --stop-signal <TAB>
ABRT IOT RTMAX-4 RTMIN RTMIN+11 TSTP
ALRM KILL RTMAX-5 RTMIN+1 RTMIN+12 TTIN
BUS PIPE RTMAX-6 RTMIN+2 RTMIN+13 TTOU
CHLD POLL RTMAX-7 RTMIN+3 RTMIN+14 URG
CLD PROF RTMAX-8 RTMIN+4 RTMIN+15 USR1
CONT PWR RTMAX-9 RTMIN+5 SEGV USR2
FPE QUIT RTMAX-10 RTMIN+6 STKFLT VTALRM
HUP RTMAX RTMAX-11 RTMIN+7 STOP WINCH
ILL RTMAX-1 RTMAX-12 RTMIN+8 SYS XCPU
INT RTMAX-2 RTMAX-13 RTMIN+9 TERM XFSZ
IO RTMAX-3 RTMAX-14 RTMIN+10 TRAP
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit b1c0ddca02
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ab8a2c0716
commit
66ec7142ae
|
@ -3,6 +3,7 @@ package container
|
|||
import (
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/moby/sys/signal"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -82,3 +83,12 @@ func completeLinuxCapabilityNames(cmd *cobra.Command, args []string, toComplete
|
|||
func completeRestartPolicies(cmd *cobra.Command, args []string, toComplete string) (names []string, _ cobra.ShellCompDirective) {
|
||||
return completion.FromList(restartPolicies...)(cmd, args, toComplete)
|
||||
}
|
||||
|
||||
func completeSignals(cmd *cobra.Command, args []string, toComplete string) (names []string, _ cobra.ShellCompDirective) {
|
||||
// TODO(thaJeztah): do we want to provide the full list here, or a subset?
|
||||
signalNames := make([]string, 0, len(signal.SignalMap))
|
||||
for k := range signal.SignalMap {
|
||||
signalNames = append(signalNames, k)
|
||||
}
|
||||
return completion.FromList(signalNames...)(cmd, args, toComplete)
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ func NewCreateCommand(dockerCli command.Cli) *cobra.Command {
|
|||
_ = cmd.RegisterFlagCompletionFunc("network", completion.NetworkNames(dockerCli))
|
||||
_ = cmd.RegisterFlagCompletionFunc("pull", completion.FromList(PullImageAlways, PullImageMissing, PullImageNever))
|
||||
_ = cmd.RegisterFlagCompletionFunc("restart", completeRestartPolicies)
|
||||
_ = cmd.RegisterFlagCompletionFunc("stop-signal", completeSignals)
|
||||
_ = cmd.RegisterFlagCompletionFunc("volumes-from", completion.ContainerNames(dockerCli, true))
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ func NewKillCommand(dockerCli command.Cli) *cobra.Command {
|
|||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
|
||||
|
||||
_ = cmd.RegisterFlagCompletionFunc("signal", completeSignals)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
@ -50,7 +53,7 @@ func runKill(ctx context.Context, dockerCli command.Cli, opts *killOptions) erro
|
|||
if err := <-errChan; err != nil {
|
||||
errs = append(errs, err.Error())
|
||||
} else {
|
||||
fmt.Fprintln(dockerCli.Out(), name)
|
||||
_, _ = fmt.Fprintln(dockerCli.Out(), name)
|
||||
}
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -43,6 +43,9 @@ func NewRestartCommand(dockerCli command.Cli) *cobra.Command {
|
|||
flags := cmd.Flags()
|
||||
flags.StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
|
||||
flags.IntVarP(&opts.timeout, "time", "t", 0, "Seconds to wait before killing the container")
|
||||
|
||||
_ = cmd.RegisterFlagCompletionFunc("signal", completeSignals)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ func NewRunCommand(dockerCli command.Cli) *cobra.Command {
|
|||
_ = cmd.RegisterFlagCompletionFunc("network", completion.NetworkNames(dockerCli))
|
||||
_ = cmd.RegisterFlagCompletionFunc("pull", completion.FromList(PullImageAlways, PullImageMissing, PullImageNever))
|
||||
_ = cmd.RegisterFlagCompletionFunc("restart", completeRestartPolicies)
|
||||
_ = cmd.RegisterFlagCompletionFunc("stop-signal", completeSignals)
|
||||
_ = cmd.RegisterFlagCompletionFunc("volumes-from", completion.ContainerNames(dockerCli, true))
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ func NewStopCommand(dockerCli command.Cli) *cobra.Command {
|
|||
flags := cmd.Flags()
|
||||
flags.StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
|
||||
flags.IntVarP(&opts.timeout, "time", "t", 0, "Seconds to wait before killing the container")
|
||||
|
||||
_ = cmd.RegisterFlagCompletionFunc("signal", completeSignals)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue