@@ -23,21 +23,26 @@ var searchStatusCmd = &cobra.Command{
2323 Short : "Show search index status and library statistics" ,
2424 RunE : func (cmd * cobra.Command , args []string ) error {
2525 idx := search .GetIndex ()
26- theme := ui .CurrentTheme ()
27-
28- titleStyle := ui .TitleStyle (theme )
29- labelStyle := ui .LabelStyle (theme )
30- valueStyle := ui .ValueStyle (theme )
3126
32- fmt .Println (titleStyle .Render ("SEARCH INDEX STATUS" ))
3327 lastIndexed := "Never"
3428 if ! idx .LastIndexed .IsZero () {
3529 lastIndexed = idx .LastIndexed .Format ("2006-01-02 15:04:05" )
3630 }
37- fmt .Printf ("%s %s\n " , labelStyle .Render ("Last Indexed:" ), valueStyle .Render (lastIndexed ))
38- fmt .Printf ("%s %s\n " , labelStyle .Render ("Total Entries:" ), valueStyle .Render (fmt .Sprintf ("%d" , len (idx .Entries ))))
3931
40- return nil
32+ data := map [string ]interface {}{
33+ "last_indexed" : lastIndexed ,
34+ "total_entries" : len (idx .Entries ),
35+ }
36+
37+ return ui.OutputData {
38+ Title : "SEARCH INDEX STATUS" ,
39+ Headers : []string {"PROPERTY" , "VALUE" },
40+ Rows : [][]string {
41+ {"Last Indexed" , lastIndexed },
42+ {"Total Entries" , fmt .Sprintf ("%d" , len (idx .Entries ))},
43+ },
44+ Raw : data ,
45+ }.Print ()
4146 },
4247}
4348
@@ -78,7 +83,6 @@ var searchFindCmd = &cobra.Command{
7883 RunE : func (cmd * cobra.Command , args []string ) error {
7984 query := strings .Join (args , " " )
8085 idx := search .GetIndex ()
81- theme := ui .CurrentTheme ()
8286
8387 if len (idx .Entries ) == 0 {
8488 return fmt .Errorf ("index is empty. Please run 'plexctl search reindex' first" )
@@ -91,31 +95,30 @@ var searchFindCmd = &cobra.Command{
9195 return nil
9296 }
9397
94- fmt .Println (ui .TitleStyle (theme ).Render (fmt .Sprintf ("Results for: %s" , query )))
95-
96- headers := []string {"TITLE" , "TYPE" , "LIBRARY" , "KEY" }
98+ headers := []string {"ID" , "TITLE" , "TYPE" , "LIBRARY" }
9799 var rows [][]string
100+ var rawResults []search.IndexEntry
98101
99102 for i , match := range matches {
100103 if i >= 20 {
101104 break
102105 }
103106 e := idx .Entries [match .Index ]
104107 rows = append (rows , []string {
108+ e .RatingKey ,
105109 e .Title ,
106110 strings .ToUpper (e .Type ),
107111 e .Library ,
108- e .RatingKey ,
109112 })
113+ rawResults = append (rawResults , e )
110114 }
111115
112- ui.OutputData {
116+ return ui.OutputData {
117+ Title : fmt .Sprintf ("Results for: %s" , query ),
113118 Headers : headers ,
114119 Rows : rows ,
115- Raw : rows , // Use rows as raw for now
120+ Raw : rawResults ,
116121 }.Print ()
117-
118- return nil
119122 },
120123}
121124
0 commit comments