Files
phylum/server/internal/command/trash/summary.go
2025-03-19 13:16:42 +05:30

35 lines
729 B
Go

package trash
import (
"fmt"
"os"
"github.com/shroff/phylum/server/internal/command/common"
"github.com/shroff/phylum/server/internal/core/fs"
"github.com/spf13/cobra"
)
func setupSummaryCommand() *cobra.Command {
cmd := cobra.Command{
Use: "summary",
Short: "List Trash Summary",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
f := common.UserFileSystem(cmd)
printTrashSummary(f)
},
}
return &cmd
}
func printTrashSummary(f fs.FileSystem) {
items, size, err := f.TrashSummary()
if err != nil {
fmt.Println("cannot get trash summary: " + err.Error())
os.Exit(1)
}
fmt.Printf("Items in trash: %d\n", items)
fmt.Printf("Space occupied: %s\n", common.FormatSize(size))
}