mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-02-04 10:38:57 -06:00
35 lines
729 B
Go
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))
|
|
}
|