diff --git a/README.md b/README.md
index bbc4486..bec9e7c 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# kanbn2md
-[Kanbn](https://github.com/basementuniverse/kanbn) is a CLI Kanban board. It stores
+[Kanbn](https://github.com/basementuniverse/kanbn) is a CLI Kanban board. It stores
the task information in markdown format and has a [vscode extension](https://github.com/basementuniverse/vscode-kanbn)
-for viewing and editing the board from vscode. What is missing is a way to render the board as a markdown table.
+for viewing and editing the board from vscode. What is missing is a way to render the board as a markdown table.
This simple program takes JSON output of `kanbn board -j` on stdin and renders a markdown table on stdout.
## Installation
@@ -16,12 +16,16 @@ go install github.com/tjdavis3/kanbn2md
## Usage
```bash
+gofmt -w main.go
+go build
kanbn board -j | kanbn2md > board.md
+kanbn board -j > .kanbn/board.json
+kanbn board -j | L:\Git\kanbn2md\kanbn2md.exe >.kanbn/board.md
```
## Example
-| Backlog | Todo | In Progress | Done |
-| --- | --- | --- | --- |
+| Backlog | Todo | In Progress | Done |
+| ---------------- | ------------------ | ------------------ | --------- |
| Comment the code | Create github repo | Create a README.md | Build app |
-| Add tests | Add error handling | | |
+| Add tests | Add error handling | | |
diff --git a/main.go b/main.go
index 19a538a..8d563d1 100644
--- a/main.go
+++ b/main.go
@@ -16,18 +16,21 @@ type KanbnColumns [][]struct {
Description string `json:"description"`
ID string `json:"id"`
Metadata struct {
- Assigned string `json:"assigned"`
- Created string `json:"created"`
- Completed string `json:"completed"`
- Progress int `json:"progress"`
- Started *string `json:"started,omitempty"`
- Tags []interface{} `json:"tags"`
- Updated string `json:"updated"`
+ Assigned string `json:"assigned"`
+ Created string `json:"created"`
+ Completed string `json:"completed"`
+ Progress int `json:"progress"`
+ Started *string `json:"started,omitempty"`
+ Tags []interface{} `json:"tags"`
+ Updated string `json:"updated"`
} `json:"metadata"`
- Name string `json:"name"`
- Progress int `json:"progress"`
- Relations []interface{} `json:"relations"`
- RemainingWorkload int `json:"remainingWorkload"`
+ Name string `json:"name"`
+ Progress int `json:"progress"`
+ Relations []struct {
+ Task string `json:"task"`
+ Type string `json:"type"`
+ } `json:"relations"`
+ RemainingWorkload int `json:"remainingWorkload"`
SubTasks []struct {
Completed bool `json:"completed"`
Text string `json:"text"`
@@ -67,6 +70,11 @@ func renderBoard(r io.Reader, w io.Writer) error {
return err
}
+ fmt.Fprintln(w, "")
+
// Determine how many columns exists and print the header row
columnCount := len(kanbn.Headings)
for _, col := range kanbn.Headings {
@@ -90,11 +98,20 @@ func renderBoard(r io.Reader, w io.Writer) error {
// convert columns of rows into rows of columns
for curCol, column := range lane.Columns {
for colRow, task := range column {
- complete := ""
- if task.Progress == 1 || task.Metadata.Completed != "" {
- complete="~~"
- }
- rows[colRow][curCol] = fmt.Sprintf("%s%s%s", complete, task.Name, complete)
+ complete := ""
+ firstRelation := ""
+ if task.Progress == 1 || task.Metadata.Completed != "" {
+ complete = "~~"
+ }
+ if len(task.Relations) > 0 {
+ firstRelation = task.Relations[0].Task
+ }
+ rows[colRow][curCol] = fmt.Sprintf("%s%s%s
%s
%s",
+ complete,
+ task.Name,
+ complete,
+ ""+task.Metadata.Created[0:10]+"",
+ ""+firstRelation+"")
}
}
// print the rows