Skip to content

Commit

Permalink
list: add basic list command (no API queries included yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
phiros committed Apr 1, 2019
1 parent 0119f7d commit e4cbefb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
30 changes: 30 additions & 0 deletions cmd-list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"github.com/spf13/cobra"
)

func init() {
listCommand.AddCommand(listProjectsCommand)
rootCmd.AddCommand(listCommand)
}

var listCommand = &cobra.Command{
Use: "list",
Short: "list entries, projects and roles",
Run: func(cmd *cobra.Command, args []string) {
// TODO: list entries for last 7 days by default
},
}

var listProjectsCommand = &cobra.Command{
Use: "projects",
Short: "list projects",
Run: func(cmd *cobra.Command, args []string) {
url := configGetApiUrl()
key := configGetApiKey()
// do get request
fmt.Println(url, key)
},
}
2 changes: 1 addition & 1 deletion cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var rootCmd = &cobra.Command{
Use: "mite-go",
Short: "cli client for mite time tracking",
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
// list entries for last 7 days
},
}

Expand Down
8 changes: 8 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import (
"path/filepath"
)

func configGetApiUrl() string {
configGet("api.url")
}

func configGetApiKey() string {
configGet("api.key")
}

func configGet(key string) string {
err := viper.ReadInConfig()
if err != nil {
Expand Down

0 comments on commit e4cbefb

Please sign in to comment.