listcmd

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "ls",
	Aliases: []string{"list"},
	Short:   "List indexed files",
	RunE: func(cmd *cobra.Command, args []string) error {
		serverURL, err := cmd.Flags().GetString("server")
		if err != nil {
			return fmt.Errorf("get server flag: %w", err)
		}
		c, err := syclient.New(serverURL)
		if err != nil {
			return err
		}
		resp, err := c.Index().List(cmd.Context(), syclient.ListRecordsOptions{
			Limit:        listLimit,
			Page:         listPage,
			Organization: strings.TrimSpace(listOrganization),
			ProjectID:    strings.TrimSpace(listProject),
		})
		if err != nil {
			return err
		}

		records := resp.GetRecords()
		if len(records) == 0 {
			fmt.Fprintln(cmd.OutOrStdout(), "no records found")
			return nil
		}

		sort.Slice(records, func(i, j int) bool {
			return strings.TrimSpace(records[i].GetDid()) < strings.TrimSpace(records[j].GetDid())
		})
		for _, rec := range records {
			did := strings.TrimSpace(rec.GetDid())
			name := strings.TrimSpace(rec.GetFileName())
			if name == "" {
				name = "-"
			}
			size := rec.GetSize()
			fmt.Fprintf(cmd.OutOrStdout(), "%s\t%s\t%d\n", did, name, size)
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL