1package commands
2
3import (
4 "github.com/spf13/cobra"
5)
6
7func newLsIdCommand() *cobra.Command {
8 env := newEnv()
9
10 cmd := &cobra.Command{
11 Use: "ls-id [PREFIX]",
12 Short: "List bug identifiers.",
13 PreRunE: loadBackend(env),
14 RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
15 return runLsId(env, args)
16 }),
17 Deprecated: `and will be removed in v1.0.
18
19Please use the "ls" command which allows filtering and sorting of the resulting
20list of ids. The following example would print a new-line separated list containing
21the ids of all open bugs:
22git-bug ls --format id --status open
23`,
24 }
25
26 return cmd
27}
28
29func runLsId(env *Env, args []string) error {
30 var prefix = ""
31 if len(args) != 0 {
32 prefix = args[0]
33 }
34
35 for _, id := range env.backend.AllBugsIds() {
36 if prefix == "" || id.HasPrefix(prefix) {
37 env.out.Println(id)
38 }
39 }
40
41 return nil
42}