-
Notifications
You must be signed in to change notification settings - Fork 0
/
up.go
36 lines (29 loc) · 1.01 KB
/
up.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cmd
import (
"github.com/spf13/cobra"
"github.com/iyear/tdl/app/up"
"github.com/iyear/tdl/pkg/logger"
)
func NewUpload() *cobra.Command {
var opts up.Options
cmd := &cobra.Command{
Use: "upload",
Aliases: []string{"up"},
Short: "Upload anything to Telegram",
RunE: func(cmd *cobra.Command, args []string) error {
return up.Run(logger.Named(cmd.Context(), "up"), &opts)
},
}
const (
_chat = "chat"
path = "path"
)
cmd.Flags().StringVarP(&opts.Chat, _chat, "c", "", "chat id or domain, and empty means 'Saved Messages'")
cmd.Flags().StringSliceVarP(&opts.Paths, path, "p", []string{}, "dirs or files")
cmd.Flags().StringSliceVarP(&opts.Excludes, "excludes", "e", []string{}, "exclude the specified file extensions")
cmd.Flags().BoolVar(&opts.Remove, "rm", false, "remove the uploaded files after uploading")
cmd.Flags().BoolVar(&opts.Photo, "photo", false, "upload the image as a photo instead of a file")
// completion and validation
_ = cmd.MarkFlagRequired(path)
return cmd
}