2019-02-08 21:25:19 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2019-08-12 17:12:14 +03:00
|
|
|
"github.com/spf13/cobra"
|
2019-02-08 21:25:19 +03:00
|
|
|
)
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
func newLsIdCommand() *cobra.Command {
|
|
|
|
env := newEnv()
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
2021-05-09 12:33:20 +03:00
|
|
|
Use: "ls-id [PREFIX]",
|
|
|
|
Short: "List bug identifiers.",
|
|
|
|
PreRunE: loadBackend(env),
|
|
|
|
RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
|
2020-06-28 19:26:29 +03:00
|
|
|
return runLsId(env, args)
|
2021-05-09 12:33:20 +03:00
|
|
|
}),
|
2020-06-28 19:26:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
2019-02-08 21:25:19 +03:00
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
func runLsId(env *Env, args []string) error {
|
2019-03-05 15:20:58 +03:00
|
|
|
var prefix = ""
|
2019-03-04 21:33:38 +03:00
|
|
|
if len(args) != 0 {
|
|
|
|
prefix = args[0]
|
|
|
|
}
|
2019-02-08 21:25:19 +03:00
|
|
|
|
2020-06-28 20:09:32 +03:00
|
|
|
for _, id := range env.backend.AllBugsIds() {
|
2019-08-12 17:12:14 +03:00
|
|
|
if prefix == "" || id.HasPrefix(prefix) {
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Println(id)
|
2019-02-08 21:25:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 22:08:55 +03:00
|
|
|
return nil
|
2019-02-08 21:25:19 +03:00
|
|
|
}
|