MCPcopy Create free account
hub / github.com/cli/cli / NewCmdUpload

Function NewCmdUpload

pkg/cmd/release/upload/upload.go:33–76  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*UploadOptions) error)

Source from the content-addressed store, hash-verified

31}
32
33func NewCmdUpload(f *cmdutil.Factory, runF func(*UploadOptions) error) *cobra.Command {
34 opts := &UploadOptions{
35 IO: f.IOStreams,
36 HttpClient: f.HttpClient,
37 }
38
39 cmd := &cobra.Command{
40 Use: "upload <tag> <files>...",
41 Short: "Upload assets to a release",
42 Long: heredoc.Docf(`
43 Upload asset files to a GitHub Release.
44
45 To define a display label for an asset, append text starting with %[1]s#%[1]s after the
46 file name.
47
48 When using %[1]s--clobber%[1]s, existing assets are deleted before new assets are uploaded.
49 If the upload fails, the original assets will be lost.
50 `, "`"),
51 Args: cobra.MinimumNArgs(2),
52 RunE: func(cmd *cobra.Command, args []string) error {
53 // support `-R, --repo` override
54 opts.BaseRepo = f.BaseRepo
55
56 opts.TagName = args[0]
57
58 var err error
59 opts.Assets, err = shared.AssetsFromArgs(args[1:])
60 if err != nil {
61 return err
62 }
63
64 opts.Concurrency = 5
65
66 if runF != nil {
67 return runF(opts)
68 }
69 return uploadRun(opts)
70 },
71 }
72
73 cmd.Flags().BoolVar(&opts.OverwriteExisting, "clobber", false, "Delete and re-upload existing assets of the same name")
74
75 return cmd
76}
77
78func uploadRun(opts *UploadOptions) error {
79 httpClient, err := opts.HttpClient()

Callers

nothing calls this directly

Calls 2

AssetsFromArgsFunction · 0.92
uploadRunFunction · 0.85

Tested by

no test coverage detected