Skip to content

Commit

Permalink
removed file option
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticrabbit committed Nov 12, 2021
1 parent fff10f2 commit ded90ca
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ export CLICKUP_REDIRECT_PORT=9999 (optional, CLI will default to port 4321, jus
```

1. Task details will be output in JSON to StdOut.
1. You can use the -f flag to output to a file `clickup_<taskid>.json`:
```
clickup get task 123456 -f <short>
clickup get task 123456 --file <long/explicit>
```
1. If Clickup space is using custom task IDs, set the `CLICKUP_TEAM_ID` env variable to your organization team ID, and pass the -c flag:
```
clickup get task CUSTOM-1234 -c <short>
Expand Down
14 changes: 7 additions & 7 deletions cmd/gettask.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"errors"
"fmt"
"strings"

"github.com/fantasticrabbit/ClickupCLI/internal"
Expand All @@ -10,7 +11,7 @@ import (
)

var taskCmd = &cobra.Command{
Use: "task TASK_ID [-f]",
Use: "task TASK_ID",
Short: "get data for a single task by supplying it's task id",
Long: `Request JSON data for a single task in an authorized Clickup workspace`,
Args: func(cmd *cobra.Command, args []string) error {
Expand All @@ -20,21 +21,20 @@ var taskCmd = &cobra.Command{
return nil
},
Run: func(cmd *cobra.Command, args []string) {
customFlag, _ := cmd.Flags().GetBool("custom")
subtasksFlag, _ := cmd.Flags().GetBool("subtasks")
var t = internal.TaskRequest{
TaskID: strings.Trim(args[0], "#"),
CustomTask: customFlag,
CustomTask: viper.GetBool("custom"),
TeamID: viper.GetString("team_id"),
Subtasks: subtasksFlag,
Subtasks: viper.GetBool("subtasks"),
}
t.WriteOut(t.GetJSON(t.BuildPath()))
fmt.Println(t.GetJSON(t.BuildPath()))
},
}

func init() {
getCmd.AddCommand(taskCmd)
taskCmd.Flags().BoolP("custom", "c", false, "task id provided is a clickup custom task id")
viper.BindPFlag("custom", taskCmd.Flags().Lookup("custom"))
taskCmd.Flags().BoolP("subtasks", "s", false, "include subtasks in output")
taskCmd.Flags().BoolP("file", "f", false, "output to file clickup_<taskID>.json")
viper.BindPFlag("subtasks", taskCmd.Flags().Lookup("subtasks"))
}
15 changes: 0 additions & 15 deletions internal/gettask.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package internal

import (
"fmt"
"log"
"os"

"github.com/spf13/viper"
)

type TaskRequest struct {
Expand All @@ -26,17 +22,6 @@ func (t TaskRequest) BuildPath() string {
}
}

//WriteOut reads the fileout Flag and writes to StdOut or file
func (t TaskRequest) WriteOut(payload []byte) {
if !viper.GetBool("file") {
fmt.Println(string(payload))
}
err := os.WriteFile("clickup_"+t.TaskID+".json", payload, 0644)
if err != nil {
log.Fatalln("Error writing task JSON")
}
}

//GetJSON accepts an API path and returns byte payload of JSON data
func (t TaskRequest) GetJSON(apiPath string) []byte {
return getJSON(apiPath)
Expand Down
1 change: 0 additions & 1 deletion internal/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var (
type Requester interface {
BuildPath() string
GetJSON(string) []byte
WriteOut([]byte)
}

// HTTPClient interface
Expand Down

0 comments on commit ded90ca

Please sign in to comment.