MCPcopy Index your code
hub / github.com/docker/cli / newEventsCommand

Function newEventsCommand

cli/command/system/events.go:31–57  ·  view source on GitHub ↗

newEventsCommand creates a new cobra.Command for `docker events`

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

29
30// newEventsCommand creates a new cobra.Command for `docker events`
31func newEventsCommand(dockerCLI command.Cli) *cobra.Command {
32 options := eventsOptions{filter: opts.NewFilterOpt()}
33
34 cmd := &cobra.Command{
35 Use: "events [OPTIONS]",
36 Short: "Get real time events from the server",
37 Args: cli.NoArgs,
38 RunE: func(cmd *cobra.Command, args []string) error {
39 return runEvents(cmd.Context(), dockerCLI, &options)
40 },
41 Annotations: map[string]string{
42 "aliases": "docker system events, docker events",
43 },
44 ValidArgsFunction: cobra.NoFileCompletions,
45 DisableFlagsInUseLine: true,
46 }
47
48 flags := cmd.Flags()
49 flags.StringVar(&options.since, "since", "", "Show all events created since timestamp")
50 flags.StringVar(&options.until, "until", "", "Stream events until this timestamp")
51 flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")
52 flags.StringVar(&options.format, "format", "", flagsHelper.InspectFormatHelp) // using the same flag description as "inspect" commands for now.
53
54 _ = cmd.RegisterFlagCompletionFunc("filter", completeEventFilters(dockerCLI))
55
56 return cmd
57}
58
59func runEvents(ctx context.Context, dockerCLI command.Cli, options *eventsOptions) error {
60 tmpl, err := makeTemplate(options.format)

Callers 3

newSystemCommandFunction · 0.85
TestEventsFormatFunction · 0.85
TestCompleteEventFilterFunction · 0.85

Calls 2

runEventsFunction · 0.85
completeEventFiltersFunction · 0.85

Tested by 2

TestEventsFormatFunction · 0.68
TestCompleteEventFilterFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…