Import Trello lists
This commit is contained in:
parent
63d476f9d5
commit
aee503148d
1 changed files with 25 additions and 16 deletions
|
@ -2,12 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "errors"
|
// "errors"
|
||||||
// "fmt"
|
"fmt"
|
||||||
"github.com/adlio/trello"
|
"github.com/adlio/trello"
|
||||||
// "github.com/davecgh/go-spew/spew"
|
// "github.com/davecgh/go-spew/spew"
|
||||||
// "log"
|
// "log"
|
||||||
|
"net/url"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
// "strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -20,17 +21,9 @@ type TrelloCtx struct {
|
||||||
Client *trello.Client
|
Client *trello.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrelloItem struct {
|
|
||||||
Title string
|
|
||||||
}
|
|
||||||
|
|
||||||
type TrelloList struct {
|
|
||||||
Items []TrelloItem
|
|
||||||
}
|
|
||||||
|
|
||||||
type TrelloBoard struct {
|
type TrelloBoard struct {
|
||||||
Ctx TrelloCtx
|
Ctx *TrelloCtx
|
||||||
Lists []TrelloList
|
Ptr *trello.Board
|
||||||
}
|
}
|
||||||
|
|
||||||
func runcmd(command string) string {
|
func runcmd(command string) string {
|
||||||
|
@ -48,7 +41,6 @@ func runcmd(command string) string {
|
||||||
func NewTrello(token string) *TrelloCtx {
|
func NewTrello(token string) *TrelloCtx {
|
||||||
client := trello.NewClient(APP_KEY, token)
|
client := trello.NewClient(APP_KEY, token)
|
||||||
/*
|
/*
|
||||||
spew.Dump(client)
|
|
||||||
if client == nil {
|
if client == nil {
|
||||||
url := strings.Join([]string{
|
url := strings.Join([]string{
|
||||||
"https://trello.com/1/authorize?expiration=never",
|
"https://trello.com/1/authorize?expiration=never",
|
||||||
|
@ -75,10 +67,27 @@ func NewTrello(token string) *TrelloCtx {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *TrelloCtx) GetBoard(boardUrl string) TrelloBoard {
|
func (ctx *TrelloCtx) GetBoard(boardUrl string) TrelloBoard {
|
||||||
return TrelloBoard{Ctx: *ctx}
|
parsedUrl, err := url.Parse(boardUrl)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
boardId := strings.Split(parsedUrl.Path, "/")[2]
|
||||||
|
|
||||||
|
// spew.Dump(boardId)
|
||||||
|
board, err := ctx.Client.GetBoard(boardId, trello.Defaults())
|
||||||
|
// spew.Dump(board)
|
||||||
|
return TrelloBoard{Ctx: ctx, Ptr: board}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*TrelloBoard) ExportToMarkdown() []string {
|
func (board *TrelloBoard) ExportToMarkdown() []string {
|
||||||
|
// var s []string
|
||||||
|
|
||||||
|
lists, _ := board.Ptr.GetLists(trello.Defaults())
|
||||||
|
// spew.Dump(lists)
|
||||||
|
// s = append(s, "# Trello board")
|
||||||
|
for _, v := range lists {
|
||||||
|
fmt.Println(v.Name)
|
||||||
|
}
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue