-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (51 loc) · 1.1 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"encoding/csv"
"encoding/json"
"fmt"
"io"
"os"
"sort"
)
type Labels struct {
Labels []string `json:"labels"`
}
func main() {
// Read the JSON file
jf, err := os.Open("labels.json")
if err != nil {
fmt.Println("Error opening JSON file:", err)
return
}
defer jf.Close()
byteValue, err := io.ReadAll(jf)
if err != nil {
fmt.Println("Error reading JSON file:", err)
return
}
var labels Labels
err = json.Unmarshal(byteValue, &labels)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// Sort the labels alphabetically
sort.Strings(labels.Labels)
// Create a CSV f
f, err := os.Create("NFR_JQL_Scripts.csv")
if err != nil {
fmt.Println("Error creating CSV file:", err)
return
}
defer f.Close()
w := csv.NewWriter(f)
defer w.Flush()
// Write the header
w.Write([]string{"Label", "JQL Command"})
// Iterate over the labels and generate the JQL commands
for _, l := range labels.Labels {
jql := fmt.Sprintf("labels = %q ORDER BY created DESC", l)
w.Write([]string{l, jql})
}
fmt.Println("CSV file successfully created.")
}