From e4cbefb678645d731d9137c566de3acc18741587 Mon Sep 17 00:00:00 2001 From: Philipp Rosenkranz Date: Mon, 1 Apr 2019 13:54:25 +0200 Subject: [PATCH] list: add basic list command (no API queries included yet) --- cmd-list.go | 30 ++++++++++++++++++++++++++++++ cmd.go | 2 +- config.go | 8 ++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 cmd-list.go diff --git a/cmd-list.go b/cmd-list.go new file mode 100644 index 0000000..74f18f1 --- /dev/null +++ b/cmd-list.go @@ -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) + }, +} diff --git a/cmd.go b/cmd.go index a6f8719..d44e855 100644 --- a/cmd.go +++ b/cmd.go @@ -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 }, } diff --git a/config.go b/config.go index ae2cd55..0928e2a 100644 --- a/config.go +++ b/config.go @@ -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 {