Skip to content

Commit 693a50d

Browse files
committed
Add quiet flag for listing functions
This is required when users create a large amount of test functions. It lets them delete them using xargs, or run other operations by parsing the list quickly. Tested locally with Kubernetes. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 598336a commit 693a50d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

commands/list.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func init() {
2222
// Setup flags that are used by multiple commands (variables defined in faas.go)
2323
listCmd.Flags().StringVarP(&gateway, "gateway", "g", defaultGateway, "Gateway URL starting with http(s)://")
2424
listCmd.Flags().StringVarP(&functionNamespace, "namespace", "n", "", "Namespace of the function")
25+
listCmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "Quiet mode - print out only the function's ID")
2526

2627
listCmd.Flags().BoolVarP(&verboseList, "verbose", "v", false, "Verbose output for the function list")
2728
listCmd.Flags().BoolVar(&tlsInsecure, "tls-no-verify", false, "Disable TLS validation")
@@ -73,7 +74,11 @@ func runList(cmd *cobra.Command, args []string) error {
7374
return err
7475
}
7576

76-
if verboseList {
77+
if quiet {
78+
for _, function := range functions {
79+
fmt.Printf("%s\n", function.Name)
80+
}
81+
} else if verboseList {
7782
fmt.Printf("%-30s\t%-40s\t%-15s\t%-5s\n", "Function", "Image", "Invocations", "Replicas")
7883
for _, function := range functions {
7984
functionImage := function.Image
@@ -86,7 +91,6 @@ func runList(cmd *cobra.Command, args []string) error {
8691
fmt.Printf("%-30s\t%-15s\t%-5s\n", "Function", "Invocations", "Replicas")
8792
for _, function := range functions {
8893
fmt.Printf("%-30s\t%-15d\t%-5d\n", function.Name, int64(function.InvocationCount), function.Replicas)
89-
9094
}
9195
}
9296
return nil

0 commit comments

Comments
 (0)