Skip to content

Commit

Permalink
reduce repeated output call list with request func
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticrabbit committed Nov 17, 2021
1 parent bf998ee commit b2e14a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/getlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"errors"
"fmt"

"github.com/fantasticrabbit/ClickupCLI/internal"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -47,7 +46,7 @@ var listCmd = &cobra.Command{
l.ListID = args[0]
}

fmt.Println(internal.FormatJSON(l.GetJSON(l.BuildPath())))
internal.Request(l)
},
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/gettask.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"errors"
"fmt"
"strings"

"github.com/fantasticrabbit/ClickupCLI/internal"
Expand Down Expand Up @@ -34,7 +33,7 @@ var taskCmd = &cobra.Command{
Subtasks: viper.GetBool("subtasks"),
}

fmt.Println(internal.FormatJSON(t.GetJSON(t.BuildPath())))
internal.Request(t)
},
}

Expand Down
5 changes: 5 additions & 0 deletions internal/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
Expand Down Expand Up @@ -50,3 +51,7 @@ func FormatJSON(jsonresp []byte) string {
}
return formattedJSON.String()
}

func Request(r Requester) {
fmt.Println(FormatJSON(r.GetJSON(r.BuildPath())))
}

0 comments on commit b2e14a2

Please sign in to comment.