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