@@ -11,6 +11,9 @@ import (
1111
1212// // TODO: Update progress relatively. For example "+2", "-10" etc.,
1313var progress string
14+ var updateStatus string
15+ var notes string
16+ var scoreString string
1417
1518// func handleUpdate(mediaId int) {
1619// CheckIfTokenExists()
@@ -48,15 +51,32 @@ func handleUpdate(cmd *cobra.Command, args []string) {
4851 )
4952 }
5053
51- err = viewmodel .HandleMediaUpdate (
52- viewmodel.MediaUpdateParams {
53- IsNewAddition : false ,
54- MediaId : id ,
55- Progress : progress ,
56- Status : "none" ,
57- StartDate : "none" ,
58- },
59- )
54+ var scoreFloat * float64
55+ if scoreString != "" {
56+ rawScoreFloat , err := strconv .ParseFloat (scoreString , 32 )
57+ if err != nil {
58+ fmt .Println (ui .ErrorText (err ))
59+ return
60+ }
61+ scoreFloat = & rawScoreFloat
62+ }
63+
64+ params := viewmodel.MediaUpdateParams {
65+ IsNewAddition : false ,
66+ MediaId : id ,
67+ Progress : progress ,
68+ Status : updateStatus ,
69+ StartDate : "none" ,
70+ }
71+ // TODO: add a way to differentiate between an
72+ // empty notes value vs. an unset notes value
73+ if notes != "\n " {
74+ params .Notes = notes
75+ }
76+ if scoreFloat != nil {
77+ params .Score = float32 (* scoreFloat )
78+ }
79+ err = viewmodel .HandleMediaUpdate (params )
6080
6181 if err != nil {
6282 fmt .Println (ui .ErrorText (err ))
@@ -67,15 +87,28 @@ var mediaUpdateCmd = &cobra.Command{
6787 Use : "update [id]" ,
6888 Short : "Update a list entry" ,
6989 Args : cobra .MinimumNArgs (1 ),
70- Run : handleUpdate ,
90+ Run : handleUpdate ,
7191}
7292
7393func init () {
7494 mediaUpdateCmd .Flags ().StringVarP (
7595 & progress ,
7696 "progress" ,
7797 "p" ,
78- "0 " ,
98+ "" ,
7999 "The number of episodes/chapter to update" ,
80100 )
101+ mediaUpdateCmd .Flags ().StringVarP (
102+ & updateStatus , "status" , "s" , "none" , "Status of the media. Can be 'watching/w or reading/r', 'planning/p', 'completed/c', 'dropped/d', 'paused/ps'" ,
103+ )
104+ mediaUpdateCmd .Flags ().StringVarP (
105+ & notes ,
106+ "notes" ,
107+ "n" ,
108+ "\n " ,
109+ "Text notes. Note: you can add multiple lines by typing \" \\ n\" and wrapping the note in double quotes" ,
110+ )
111+ mediaUpdateCmd .Flags ().StringVarP (
112+ & scoreString , "score" , "r" , "" , "The score of the entry. If your score is in emoji, type 1 for 😞, 2 for 😐 and 3 for 😊" ,
113+ )
81114}
0 commit comments