File tree Expand file tree Collapse file tree 5 files changed +11
-13
lines changed Expand file tree Collapse file tree 5 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,19 @@ package cmd
22
33import (
44 "github.com/leanovate/mite-go/config"
5+ "github.com/leanovate/mite-go/mite"
56 "github.com/spf13/cobra"
67)
78
89type dependencies struct {
9- conf config.Config
10+ conf config.Config
11+ miteApi mite.MiteApi
1012}
1113
1214var deps dependencies
1315
14- func HandleCommands (c config.Config ) error {
15- deps = dependencies {conf : c }
16+ func HandleCommands (c config.Config , m mite. MiteApi ) error {
17+ deps = dependencies {conf : c , miteApi : m }
1618 return rootCmd .Execute ()
1719}
1820
Original file line number Diff line number Diff line change @@ -36,8 +36,6 @@ var entriesListCommand = &cobra.Command{
3636 Use : "list" ,
3737 Short : "list time entries" ,
3838 Run : func (cmd * cobra.Command , args []string ) {
39- api := mite .NewMiteApi (deps .conf .GetApiUrl (), deps .conf .GetApiKey ())
40-
4139 direction := listOrder
4240
4341 to , err := time .Parse ("2006-01-02" , listTo )
@@ -51,7 +49,7 @@ var entriesListCommand = &cobra.Command{
5149 return
5250 }
5351
54- entries , err := api .TimeEntries (& mite.TimeEntryParameters {
52+ entries , err := deps . miteApi .TimeEntries (& mite.TimeEntryParameters {
5553 To : & to ,
5654 From : & from ,
5755 Direction : direction ,
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package cmd
33import (
44 "fmt"
55 "github.com/cheynewallace/tabby"
6- "github.com/leanovate/mite-go/mite"
76 "github.com/spf13/cobra"
87 "os"
98)
@@ -23,8 +22,7 @@ var listProjectsCommand = &cobra.Command{
2322 Use : "list" ,
2423 Short : "list projects" ,
2524 Run : func (cmd * cobra.Command , args []string ) {
26- api := mite .NewMiteApi (deps .conf .GetApiUrl (), deps .conf .GetApiKey ())
27- projects , err := api .Projects ()
25+ projects , err := deps .miteApi .Projects ()
2826 if err != nil {
2927 _ , _ = fmt .Fprintln (os .Stderr , err )
3028 return
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package cmd
33import (
44 "fmt"
55 "github.com/cheynewallace/tabby"
6- "github.com/leanovate/mite-go/mite"
76 "github.com/spf13/cobra"
87 "os"
98)
@@ -23,8 +22,7 @@ var listServicesCommand = &cobra.Command{
2322 Use : "list" ,
2423 Short : "list services" ,
2524 Run : func (cmd * cobra.Command , args []string ) {
26- api := mite .NewMiteApi (deps .conf .GetApiUrl (), deps .conf .GetApiKey ())
27- services , err := api .Services ()
25+ services , err := deps .miteApi .Services ()
2826 if err != nil {
2927 _ , _ = fmt .Fprintln (os .Stderr , err )
3028 return
Original file line number Diff line number Diff line change 44 "fmt"
55 "github.com/leanovate/mite-go/cmd"
66 "github.com/leanovate/mite-go/config"
7+ "github.com/leanovate/mite-go/mite"
78 "github.com/mitchellh/go-homedir"
89 "os"
910)
@@ -17,8 +18,9 @@ func main() {
1718 _ , _ = fmt .Fprintln (os .Stderr , err )
1819 }
1920 c := config .NewConfig (configFileName , homeDirectory , configType )
21+ api := mite .NewMiteApi (c .GetApiUrl (), c .GetApiKey ())
2022
21- err = cmd .HandleCommands (c )
23+ err = cmd .HandleCommands (c , api )
2224 if err != nil {
2325 _ , _ = fmt .Fprintln (os .Stderr , err )
2426 os .Exit (1 )
You can’t perform that action at this time.
0 commit comments