zeit/z/list.go

40 lines
677 B
Go
Raw Normal View History

2020-10-15 21:45:14 +00:00
package z
import (
"os"
"fmt"
"github.com/spf13/cobra"
)
var listCmd = &cobra.Command{
Use: "list",
2020-10-16 00:08:49 +00:00
Short: "List activities",
Long: "List all tracked activities.",
2020-10-15 21:45:14 +00:00
Run: func(cmd *cobra.Command, args []string) {
user := GetCurrentUser()
entries, err := database.ListEntries(user)
if err != nil {
fmt.Printf("%s %+v\n", CharError, err)
os.Exit(1)
}
for _, entry := range entries {
fmt.Printf("%s\n", entry.GetOutput())
}
return
},
}
func init() {
rootCmd.AddCommand(listCmd)
var err error
database, err = InitDatabase()
if err != nil {
fmt.Printf("%s %+v\n", CharError, err)
os.Exit(1)
}
}