-
Notifications
You must be signed in to change notification settings - Fork 3
/
show.go
45 lines (37 loc) · 960 Bytes
/
show.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cmd
import (
"fmt"
"github.com/HeySquirrel/tribe/work"
"github.com/kennygrant/sanitize"
"github.com/spf13/cobra"
"io"
"os"
)
var ShowCmd = &cobra.Command{
Use: "show",
Short: "Show relevant information about a given work item or issue",
Long: `See the name, description and owner for relevant work items or issues in CA Agile Central or Jira.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
workitemid := args[0]
api, err := work.NewItemServer()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
workitem, err := api.GetItem(workitemid)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
Display(os.Stdout, workitem)
},
}
func Display(writer io.Writer, workitem work.Item) {
fmt.Fprintln(writer)
fmt.Fprintf(writer, "%s - %s\n\n", workitem.GetId(), workitem.GetName())
fmt.Fprintln(writer, sanitize.HTML(workitem.GetDescription()))
}
func init() {
RootCmd.AddCommand(ShowCmd)
}