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

Function newCreateCommand

cli/command/context/create.go:44–62  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

42}
43
44func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
45 opts := createOptions{}
46 cmd := &cobra.Command{
47 Use: "create [OPTIONS] CONTEXT",
48 Short: "Create a context",
49 Args: cli.ExactArgs(1),
50 RunE: func(cmd *cobra.Command, args []string) error {
51 return runCreate(dockerCLI, args[0], opts)
52 },
53 Long: longCreateDescription(),
54 ValidArgsFunction: cobra.NoFileCompletions,
55 DisableFlagsInUseLine: true,
56 }
57 flags := cmd.Flags()
58 flags.StringVar(&opts.description, "description", "", "Description of the context")
59 flags.StringToStringVar(&opts.endpoint, "docker", nil, "set the docker endpoint")
60 flags.StringVar(&opts.from, "from", "", "create context from a named context")
61 return cmd
62}
63
64// runCreate creates a Docker context
65func runCreate(dockerCLI command.Cli, name string, opts createOptions) error {

Callers 1

newContextCommandFunction · 0.70

Calls 2

longCreateDescriptionFunction · 0.85
runCreateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…