media: add --description and --focus flags for attachments
authorMikael Berthe <mikael@lilotux.net>
Tue, 20 Mar 2018 20:52:11 +0100
changeset 201 5cb568653fc7
parent 200 488f5fc5be98
child 202 1c058699177b
media: add --description and --focus flags for attachments
cmd/media.go
--- a/cmd/media.go	Tue Mar 20 19:22:14 2018 +0100
+++ b/cmd/media.go	Tue Mar 20 20:52:11 2018 +0100
@@ -13,7 +13,9 @@
 )
 
 var mediaOpts struct {
-	filePath string
+	filePath    string
+	description string
+	focus       string
 }
 
 // mediaCmd represents the media command
@@ -30,6 +32,9 @@
 
 	mediaCmd.Flags().StringVar(&mediaOpts.filePath, "file", "", "Path of the media file")
 	mediaCmd.MarkFlagRequired("file")
+
+	mediaCmd.Flags().StringVar(&mediaOpts.description, "description", "", "Plain text description")
+	mediaCmd.Flags().StringVar(&mediaOpts.focus, "focus", "", "Focal point")
 }
 
 func mediaRunE(cmd *cobra.Command, args []string) error {
@@ -43,7 +48,7 @@
 		return err
 	}
 
-	attachment, err := gClient.UploadMedia(opt.filePath)
+	attachment, err := gClient.UploadMedia(opt.filePath, opt.description, opt.focus)
 	if err != nil {
 		errPrint("Error: %s", err.Error())
 		os.Exit(1)
@@ -59,7 +64,7 @@
 
 // uploadFile uploads a media file and returns the attachment ID
 func uploadFile(filePath string) (int64, error) {
-	attachment, err := gClient.UploadMedia(filePath)
+	attachment, err := gClient.UploadMedia(filePath, "", "")
 	if err != nil {
 		return 0, err
 	}