Created and Relations
Some checks failed
release-please / release-please (push) Has been cancelled

This commit is contained in:
2023-06-30 13:14:19 -07:00
parent 71fb44592b
commit b65befe761
2 changed files with 42 additions and 21 deletions

View File

@ -16,12 +16,16 @@ go install github.com/tjdavis3/kanbn2md
## Usage ## Usage
```bash ```bash
gofmt -w main.go
go build
kanbn board -j | kanbn2md > board.md kanbn board -j | kanbn2md > board.md
kanbn board -j > .kanbn/board.json
kanbn board -j | L:\Git\kanbn2md\kanbn2md.exe >.kanbn/board.md
``` ```
## Example ## Example
| Backlog | Todo | In Progress | Done | | Backlog | Todo | In Progress | Done |
| --- | --- | --- | --- | | ---------------- | ------------------ | ------------------ | --------- |
| Comment the code | Create github repo | Create a README.md | Build app | | Comment the code | Create github repo | Create a README.md | Build app |
| Add tests | Add error handling | | | | Add tests | Add error handling | | |

23
main.go
View File

@ -26,7 +26,10 @@ type KanbnColumns [][]struct {
} `json:"metadata"` } `json:"metadata"`
Name string `json:"name"` Name string `json:"name"`
Progress int `json:"progress"` Progress int `json:"progress"`
Relations []interface{} `json:"relations"` Relations []struct {
Task string `json:"task"`
Type string `json:"type"`
} `json:"relations"`
RemainingWorkload int `json:"remainingWorkload"` RemainingWorkload int `json:"remainingWorkload"`
SubTasks []struct { SubTasks []struct {
Completed bool `json:"completed"` Completed bool `json:"completed"`
@ -67,6 +70,11 @@ func renderBoard(r io.Reader, w io.Writer) error {
return err return err
} }
fmt.Fprintln(w, "<style>")
fmt.Fprintln(w, "created { color: gray }")
fmt.Fprintln(w, "relations { color: Green }")
fmt.Fprintln(w, "</style>")
// Determine how many columns exists and print the header row // Determine how many columns exists and print the header row
columnCount := len(kanbn.Headings) columnCount := len(kanbn.Headings)
for _, col := range kanbn.Headings { for _, col := range kanbn.Headings {
@ -91,10 +99,19 @@ func renderBoard(r io.Reader, w io.Writer) error {
for curCol, column := range lane.Columns { for curCol, column := range lane.Columns {
for colRow, task := range column { for colRow, task := range column {
complete := "" complete := ""
firstRelation := ""
if task.Progress == 1 || task.Metadata.Completed != "" { if task.Progress == 1 || task.Metadata.Completed != "" {
complete="~~" complete = "~~"
} }
rows[colRow][curCol] = fmt.Sprintf("%s%s%s", complete, task.Name, complete) if len(task.Relations) > 0 {
firstRelation = task.Relations[0].Task
}
rows[colRow][curCol] = fmt.Sprintf("%s%s%s<br />%s<br />%s",
complete,
task.Name,
complete,
"<created>"+task.Metadata.Created[0:10]+"</created>",
"<relations>"+firstRelation+"</relations>")
} }
} }
// print the rows // print the rows