github.com/apptainer/singularity@v3.1.1+incompatible/cmd/internal/cli/capability_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  	"github.com/spf13/cobra"
    10  	"github.com/sylabs/singularity/docs"
    11  	"github.com/sylabs/singularity/internal/app/singularity"
    12  	"github.com/sylabs/singularity/internal/pkg/buildcfg"
    13  	"github.com/sylabs/singularity/internal/pkg/sylog"
    14  )
    15  
    16  func init() {
    17  	CapabilityListCmd.Flags().SetInterspersed(false)
    18  }
    19  
    20  // CapabilityListCmd singularity capability list
    21  var CapabilityListCmd = &cobra.Command{
    22  	Args:                  cobra.RangeArgs(0, 1),
    23  	DisableFlagsInUseLine: true,
    24  	Run: func(cmd *cobra.Command, args []string) {
    25  		userGroup := ""
    26  		if len(args) == 1 {
    27  			userGroup = args[0]
    28  		}
    29  		c := singularity.CapListConfig{
    30  			User:  userGroup,
    31  			Group: userGroup,
    32  			All:   len(args) == 0,
    33  		}
    34  
    35  		if err := singularity.CapabilityList(buildcfg.CAPABILITY_FILE, c); err != nil {
    36  			sylog.Fatalf("Unable to list capabilities: %s", err)
    37  		}
    38  	},
    39  
    40  	Use:     docs.CapabilityListUse,
    41  	Short:   docs.CapabilityListShort,
    42  	Long:    docs.CapabilityListLong,
    43  	Example: docs.CapabilityListExample,
    44  }