listcmd

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 9 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 {
		c, err := cliauth.NewServerClient(cmd)
		if err != nil {
			return err
		}
		resp, err := c.Index().List(cmd.Context(), syfonclient.ListRecordsOptions{
			Limit:        listLimit,
			Page:         listPage,
			Organization: strings.TrimSpace(listOrganization),
			ProjectID:    strings.TrimSpace(listProject),
		})
		if err != nil {
			return err
		}

		var records []internalapi.InternalRecord
		if resp.Records != nil {
			records = *resp.Records
		}
		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].Did) < strings.TrimSpace(records[j].Did)
		})
		tw := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 2, ' ', 0)
		fmt.Fprintln(tw, "NAME\tORG\tPROJECT\tSIZE\tDID")
		for _, rec := range records {
			did := strings.TrimSpace(rec.Did)
			name := "-"
			if rec.FileName != nil {
				name = strings.TrimSpace(*rec.FileName)
			}
			size := int64(0)
			if rec.Size != nil {
				size = *rec.Size
			}
			org := ""
			if rec.Organization != nil {
				org = strings.TrimSpace(*rec.Organization)
			}
			project := ""
			if rec.Project != nil {
				project = strings.TrimSpace(*rec.Project)
			}
			fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n", name, org, project, upload.FormatSize(size), did)
		}
		return tw.Flush()
	},
}

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