github.com/apptainer/singularity@v3.1.1+incompatible/cmd/internal/cli/cache_list_linux.go (about) 1 // Copyright (c) 2018-2019, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package cli 7 8 import ( 9 "os" 10 11 "github.com/spf13/cobra" 12 "github.com/sylabs/singularity/docs" 13 "github.com/sylabs/singularity/internal/app/singularity" 14 "github.com/sylabs/singularity/internal/pkg/sylog" 15 ) 16 17 var ( 18 cacheListTypes []string 19 allList bool 20 ) 21 22 func init() { 23 CacheListCmd.Flags().SetInterspersed(false) 24 25 CacheListCmd.Flags().StringSliceVarP(&cacheListTypes, "type", "T", []string{"library", "oci", "blobSum"}, 26 "a list of cache types to display, possible entries: library, oci, blob(s), blobSum, all") 27 CacheListCmd.Flags().SetAnnotation("type", "envkey", []string{"TYPE"}) 28 29 CacheListCmd.Flags().BoolVarP(&allList, "all", "a", false, "list all cache types") 30 CacheListCmd.Flags().SetAnnotation("all", "envkey", []string{"ALL"}) 31 } 32 33 // CacheListCmd : is `singularity cache list' and will list your local singularity cache 34 var CacheListCmd = &cobra.Command{ 35 Args: cobra.ExactArgs(0), 36 DisableFlagsInUseLine: true, 37 Run: func(cmd *cobra.Command, args []string) { 38 if err := cacheListCmd(); err != nil { 39 os.Exit(2) 40 } 41 }, 42 43 Use: docs.CacheListUse, 44 Short: docs.CacheListShort, 45 Long: docs.CacheListLong, 46 Example: docs.CacheListExample, 47 } 48 49 func cacheListCmd() error { 50 51 err := singularity.ListSingularityCache(cacheListTypes, allList) 52 if err != nil { 53 sylog.Fatalf("Not listing cache; an error occured: %v", err) 54 return err 55 } 56 return err 57 }