Implemented list command
This commit is contained in:
parent
b5c4204c38
commit
1ebf9c043f
1 changed files with 39 additions and 0 deletions
39
z/list.go
Normal file
39
z/list.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package z
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List activity",
|
||||
Long: "List all tracked activity.",
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue