This commit is contained in:
14
README.md
14
README.md
@ -1,8 +1,8 @@
|
|||||||
# kanbn2md
|
# 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)
|
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.
|
This simple program takes JSON output of `kanbn board -j` on stdin and renders a markdown table on stdout.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -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 | | |
|
||||||
|
49
main.go
49
main.go
@ -16,18 +16,21 @@ type KanbnColumns [][]struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Metadata struct {
|
Metadata struct {
|
||||||
Assigned string `json:"assigned"`
|
Assigned string `json:"assigned"`
|
||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
Completed string `json:"completed"`
|
Completed string `json:"completed"`
|
||||||
Progress int `json:"progress"`
|
Progress int `json:"progress"`
|
||||||
Started *string `json:"started,omitempty"`
|
Started *string `json:"started,omitempty"`
|
||||||
Tags []interface{} `json:"tags"`
|
Tags []interface{} `json:"tags"`
|
||||||
Updated string `json:"updated"`
|
Updated string `json:"updated"`
|
||||||
} `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 {
|
||||||
RemainingWorkload int `json:"remainingWorkload"`
|
Task string `json:"task"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
} `json:"relations"`
|
||||||
|
RemainingWorkload int `json:"remainingWorkload"`
|
||||||
SubTasks []struct {
|
SubTasks []struct {
|
||||||
Completed bool `json:"completed"`
|
Completed bool `json:"completed"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
@ -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 {
|
||||||
@ -90,11 +98,20 @@ func renderBoard(r io.Reader, w io.Writer) error {
|
|||||||
// convert columns of rows into rows of columns
|
// convert columns of rows into rows of columns
|
||||||
for curCol, column := range lane.Columns {
|
for curCol, column := range lane.Columns {
|
||||||
for colRow, task := range column {
|
for colRow, task := range column {
|
||||||
complete := ""
|
complete := ""
|
||||||
if task.Progress == 1 || task.Metadata.Completed != "" {
|
firstRelation := ""
|
||||||
complete="~~"
|
if task.Progress == 1 || task.Metadata.Completed != "" {
|
||||||
}
|
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
|
||||||
|
Reference in New Issue
Block a user