/
capability_list_linux.go
55 lines (45 loc) · 1.91 KB
/
capability_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
// 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 (
"github.com/spf13/cobra"
"github.com/sylabs/singularity/docs"
"github.com/sylabs/singularity/internal/app/singularity"
"github.com/sylabs/singularity/internal/pkg/buildcfg"
"github.com/sylabs/singularity/internal/pkg/sylog"
)
func init() {
// -u|--user
CapabilityListCmd.Flags().StringVarP(&CapUser, "user", "u", "", "list capabilities for the given user")
CapabilityListCmd.Flags().SetAnnotation("user", "argtag", []string{"<user>"})
CapabilityListCmd.Flags().SetAnnotation("user", "envkey", []string{"USER"})
// -g|--group
CapabilityListCmd.Flags().StringVarP(&CapGroup, "group", "g", "", "list capabilities for the given group")
CapabilityListCmd.Flags().SetAnnotation("group", "argtag", []string{"<group>"})
CapabilityListCmd.Flags().SetAnnotation("group", "envkey", []string{"GROUP"})
// -a|--all
CapabilityListCmd.Flags().BoolVarP(&CapListAll, "all", "a", false, "list all users and groups capabilities")
CapabilityListCmd.Flags().SetAnnotation("all", "envkey", []string{"ALL"})
CapabilityListCmd.Flags().SetInterspersed(false)
}
// CapabilityListCmd singularity capability list
var CapabilityListCmd = &cobra.Command{
Args: cobra.MinimumNArgs(0),
DisableFlagsInUseLine: true,
Run: func(cmd *cobra.Command, args []string) {
c := singularity.CapListConfig{
User: CapUser,
Group: CapGroup,
All: CapListAll,
}
if err := singularity.CapabilityList(buildcfg.CAPABILITY_FILE, c); err != nil {
sylog.Fatalf("Unable to list capabilities: %s", err)
}
},
Use: docs.CapabilityListUse,
Short: docs.CapabilityListShort,
Long: docs.CapabilityListLong,
Example: docs.CapabilityListExample,
}