@@ -71,14 +71,19 @@ type SingleResponse struct {
7171 NextFileName string `msgpack:"next_file_name"`
7272}
7373
74- type ListResponse struct {
74+ type ShortResponse struct {
7575 Name string `msgpack:"name"`
7676 Frontmatter map [string ]any `msgpack:"frontmatter,omitempty"`
7777 OneLiner string `msgpack:"one_liner,omitempty"`
7878 Modified string `msgpack:"modified"`
7979 Created string `msgpack:"created"`
8080}
8181
82+ type ListResponse struct {
83+ Files []ShortResponse `msgpack:"files"`
84+ Total uint `msgpack:"total"`
85+ }
86+
8287type Client struct {
8388 socketPath string
8489}
@@ -90,7 +95,7 @@ func NewClient(socketPath string) *Client {
9095 return & c
9196}
9297
93- func (c * Client ) runListRequest (listReq any , tag string ) ([] ListResponse , error ) {
98+ func (c * Client ) runListRequest (listReq any , tag string ) (* ListResponse , error ) {
9499 conn , err := net .Dial ("unix" , c .socketPath )
95100 if err != nil {
96101 return nil , fmt .Errorf ("Failed to dial: %w" , err )
@@ -115,12 +120,12 @@ func (c *Client) runListRequest(listReq any, tag string) ([]ListResponse, error)
115120
116121 switch resp .Tag {
117122 case "Ok" :
118- var listResp [] ListResponse
123+ var listResp ListResponse
119124 err := msgpack .Unmarshal (resp .Value , & listResp )
120125 if err != nil {
121126 return nil , fmt .Errorf ("Could not unmarshal response value: %w" , err )
122127 }
123- return listResp , nil
128+ return & listResp , nil
124129 case "InternalServerError" :
125130 return nil , fmt .Errorf ("Custard had internal server error" )
126131 default :
@@ -215,11 +220,11 @@ func (c *Client) QuerySingle(req QuerySingleRequest) (*SingleResponse, error) {
215220 return c .runSingleRequest (req , "SingleQuery" )
216221}
217222
218- func (c * Client ) GetList (req GetListRequest ) ([] ListResponse , error ) {
223+ func (c * Client ) GetList (req GetListRequest ) (* ListResponse , error ) {
219224 return c .runListRequest (req , "ListGet" )
220225}
221226
222- func (c * Client ) QueryList (req QueryListRequest ) ([] ListResponse , error ) {
227+ func (c * Client ) QueryList (req QueryListRequest ) (* ListResponse , error ) {
223228 return c .runListRequest (req , "ListQuery" )
224229}
225230
0 commit comments