forked from hibiken/asynq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2022 Kentaro Hibino. All rights reserved. | ||
// Use of this source code is governed by a MIT license | ||
// that can be found in the LICENSE file. | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(groupCmd) | ||
groupCmd.AddCommand(groupListCmd) | ||
groupListCmd.Flags().StringP("queue", "q", "", "queue to inspect") | ||
groupListCmd.MarkFlagRequired("queue") | ||
} | ||
|
||
var groupCmd = &cobra.Command{ | ||
Use: "group", | ||
Short: "Manage groups", | ||
} | ||
|
||
var groupListCmd = &cobra.Command{ | ||
Use: "ls", | ||
Short: "List groups", | ||
Args: cobra.NoArgs, | ||
Run: groupLists, | ||
} | ||
|
||
func groupLists(cmd *cobra.Command, args []string) { | ||
qname, err := cmd.Flags().GetString("queue") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
inspector := createInspector() | ||
groups, err := inspector.Groups(qname) | ||
if len(groups) == 0 { | ||
fmt.Printf("No groups found in queue %q\n", qname) | ||
return | ||
} | ||
for _, g := range groups { | ||
fmt.Println(g.Group) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters