imap-notes/cmd/folders.go

42 lines
880 B
Go
Raw Normal View History

package cmd
import (
"fmt"
"git.iamthefij.com/iamthefij/imap-notes/lib"
"git.iamthefij.com/iamthefij/slog"
"github.com/spf13/cobra"
)
var foldersCmd = &cobra.Command{
Use: "folders",
Short: "List or access folder actions",
Aliases: []string{"folder"},
Run: func(cmd *cobra.Command, args []string) {
// Should execute the list command
},
}
var foldersListCmd = &cobra.Command{
Use: "list",
Short: "List folders",
2022-02-11 23:53:36 +00:00
Args: cobra.NoArgs,
Aliases: []string{"ls"},
Run: func(cmd *cobra.Command, args []string) {
client, err := lib.GetClient()
slog.OnErrFatalf(err, "failed to logon")
folders, err := client.ListNoteFolders()
slog.OnErrFatalf(err, "failed to list folders")
for _, folder := range folders {
fmt.Println(folder.Name)
}
},
}
func addFoldersCmd() {
rootCmd.AddCommand(foldersCmd)
foldersCmd.AddCommand(foldersListCmd)
}