@@ -15,16 +15,25 @@ var commentCmd = &cobra.Command{
1515
1616var commentListCmd = & cobra.Command {
1717 Use : "list" ,
18- Short : "List comments on a task or list " ,
18+ Short : "List comments on a task, list, or view " ,
1919 RunE : func (cmd * cobra.Command , args []string ) error {
2020 client := getClient ()
2121 ctx := context .Background ()
2222 taskID , _ := cmd .Flags ().GetString ("task" )
2323 listID , _ := cmd .Flags ().GetString ("list" )
24- if taskID == "" && listID == "" {
25- output .PrintError ("VALIDATION_ERROR" , "--task or --list is required" )
24+ viewID , _ := cmd .Flags ().GetString ("view-id" )
25+ if taskID == "" && listID == "" && viewID == "" {
26+ output .PrintError ("VALIDATION_ERROR" , "--task, --list, or --view-id is required" )
2627 return & exitError {code : 1 }
2728 }
29+ if viewID != "" {
30+ resp , err := client .ListViewComments (ctx , viewID )
31+ if err != nil {
32+ return handleError (err )
33+ }
34+ output .JSON (resp )
35+ return nil
36+ }
2837 if listID != "" {
2938 resp , err := client .ListListComments (ctx , listID )
3039 if err != nil {
@@ -44,14 +53,15 @@ var commentListCmd = &cobra.Command{
4453
4554var commentCreateCmd = & cobra.Command {
4655 Use : "create" ,
47- Short : "Add a comment to a task" ,
56+ Short : "Add a comment to a task, list, or view " ,
4857 RunE : func (cmd * cobra.Command , args []string ) error {
4958 client := getClient ()
5059 ctx := context .Background ()
5160 taskID , _ := cmd .Flags ().GetString ("task" )
5261 listID , _ := cmd .Flags ().GetString ("list" )
53- if taskID == "" && listID == "" {
54- output .PrintError ("VALIDATION_ERROR" , "--task or --list is required" )
62+ viewID , _ := cmd .Flags ().GetString ("view-id" )
63+ if taskID == "" && listID == "" && viewID == "" {
64+ output .PrintError ("VALIDATION_ERROR" , "--task, --list, or --view-id is required" )
5565 return & exitError {code : 1 }
5666 }
5767 text , _ := cmd .Flags ().GetString ("text" )
@@ -66,6 +76,14 @@ var commentCreateCmd = &cobra.Command{
6676 }
6777 req .NotifyAll , _ = cmd .Flags ().GetBool ("notify-all" )
6878
79+ if viewID != "" {
80+ resp , err := client .CreateViewComment (ctx , viewID , req )
81+ if err != nil {
82+ return handleError (err )
83+ }
84+ output .JSON (resp )
85+ return nil
86+ }
6987 if listID != "" {
7088 resp , err := client .CreateListComment (ctx , listID , req )
7189 if err != nil {
@@ -135,12 +153,70 @@ var commentDeleteCmd = &cobra.Command{
135153 },
136154}
137155
156+ var commentReplyCmd = & cobra.Command {
157+ Use : "reply" ,
158+ Short : "Manage threaded comment replies" ,
159+ }
160+
161+ var commentReplyListCmd = & cobra.Command {
162+ Use : "list" ,
163+ Short : "List threaded comments on a comment" ,
164+ RunE : func (cmd * cobra.Command , args []string ) error {
165+ client := getClient ()
166+ ctx := context .Background ()
167+ commentID , _ := cmd .Flags ().GetString ("comment-id" )
168+ if commentID == "" {
169+ output .PrintError ("VALIDATION_ERROR" , "--comment-id is required" )
170+ return & exitError {code : 1 }
171+ }
172+ resp , err := client .ListThreadedComments (ctx , commentID )
173+ if err != nil {
174+ return handleError (err )
175+ }
176+ output .JSON (resp )
177+ return nil
178+ },
179+ }
180+
181+ var commentReplyCreateCmd = & cobra.Command {
182+ Use : "create" ,
183+ Short : "Create a threaded comment reply" ,
184+ RunE : func (cmd * cobra.Command , args []string ) error {
185+ client := getClient ()
186+ ctx := context .Background ()
187+ commentID , _ := cmd .Flags ().GetString ("comment-id" )
188+ if commentID == "" {
189+ output .PrintError ("VALIDATION_ERROR" , "--comment-id is required" )
190+ return & exitError {code : 1 }
191+ }
192+ text , _ := cmd .Flags ().GetString ("text" )
193+ if text == "" {
194+ output .PrintError ("VALIDATION_ERROR" , "--text is required" )
195+ return & exitError {code : 1 }
196+ }
197+ req := & api.CreateCommentRequest {CommentText : text }
198+ if cmd .Flags ().Changed ("assignee" ) {
199+ v , _ := cmd .Flags ().GetInt ("assignee" )
200+ req .Assignee = api .IntPtr (v )
201+ }
202+ req .NotifyAll , _ = cmd .Flags ().GetBool ("notify-all" )
203+ resp , err := client .CreateThreadedComment (ctx , commentID , req )
204+ if err != nil {
205+ return handleError (err )
206+ }
207+ output .JSON (resp )
208+ return nil
209+ },
210+ }
211+
138212func init () {
139213 commentListCmd .Flags ().String ("task" , "" , "Task ID" )
140214 commentListCmd .Flags ().String ("list" , "" , "List ID" )
215+ commentListCmd .Flags ().String ("view-id" , "" , "View ID (chat view comments)" )
141216
142217 commentCreateCmd .Flags ().String ("task" , "" , "Task ID" )
143218 commentCreateCmd .Flags ().String ("list" , "" , "List ID" )
219+ commentCreateCmd .Flags ().String ("view-id" , "" , "View ID (chat view comment)" )
144220 commentCreateCmd .Flags ().String ("text" , "" , "Comment text" )
145221 commentCreateCmd .Flags ().Int ("assignee" , 0 , "Assignee user ID" )
146222 commentCreateCmd .Flags ().Bool ("notify-all" , false , "Notify all" )
@@ -152,9 +228,19 @@ func init() {
152228
153229 commentDeleteCmd .Flags ().String ("id" , "" , "Comment ID" )
154230
231+ commentReplyListCmd .Flags ().String ("comment-id" , "" , "Comment ID" )
232+ commentReplyCreateCmd .Flags ().String ("comment-id" , "" , "Comment ID" )
233+ commentReplyCreateCmd .Flags ().String ("text" , "" , "Comment text" )
234+ commentReplyCreateCmd .Flags ().Int ("assignee" , 0 , "Assignee user ID" )
235+ commentReplyCreateCmd .Flags ().Bool ("notify-all" , false , "Notify all" )
236+
237+ commentReplyCmd .AddCommand (commentReplyListCmd )
238+ commentReplyCmd .AddCommand (commentReplyCreateCmd )
239+
155240 commentCmd .AddCommand (commentListCmd )
156241 commentCmd .AddCommand (commentCreateCmd )
157242 commentCmd .AddCommand (commentUpdateCmd )
158243 commentCmd .AddCommand (commentDeleteCmd )
244+ commentCmd .AddCommand (commentReplyCmd )
159245 rootCmd .AddCommand (commentCmd )
160246}
0 commit comments