MCPcopy Create free account
hub / github.com/bufbuild/buf / NewCommand

Function NewCommand

cmd/buf/internal/command/push/push.go:67–91  ·  view source on GitHub ↗

NewCommand returns a new Command.

(
	name string,
	builder appext.SubCommandBuilder,
)

Source from the content-addressed store, hash-verified

65
66// NewCommand returns a new Command.
67func NewCommand(
68 name string,
69 builder appext.SubCommandBuilder,
70) *appcmd.Command {
71 flags := newFlags()
72 return &appcmd.Command{
73 Use: name + " <source>",
74 Short: "Push to a registry",
75 Long: bufcli.GetSourceLong(`the source to push`),
76 Args: appcmd.MaximumNArgs(1),
77 Run: builder.NewRunFunc(
78 func(ctx context.Context, container appext.Container) error {
79 return run(ctx, container, flags)
80 },
81 ),
82 BindFlags: flags.Bind,
83 ModifyCobra: func(cmd *cobra.Command) error {
84 return errors.Join(
85 bufcli.RegisterFlagCompletionErrorFormat(cmd, errorFormatFlagName),
86 cmd.RegisterFlagCompletionFunc(labelFlagName, cobra.NoFileCompletions),
87 cmd.RegisterFlagCompletionFunc(sourceControlURLFlagName, cobra.NoFileCompletions),
88 )
89 },
90 }
91}
92
93type flags struct {
94 Tags []string

Callers 1

newRootCommandFunction · 0.92

Calls 4

GetSourceLongFunction · 0.92
newFlagsFunction · 0.70
runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…