Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "habitifocus", Short: "sync OmniFocus tasks to Habitica", Run: func(cmd *cobra.Command, args []string) { tasks, err := omnifocus.GetTasks() if err != nil { log.Fatal(err) } logrus.WithField("tasks", len(tasks)).Info("got OmniFocus task list") client := habitica.Client{ UserID: viper.GetString("userid"), APIKey: viper.GetString("apikey"), } remoteTasks, err := client.List() if err != nil { log.Fatal(err) } logrus.WithField("tasks", len(remoteTasks)).Info("got Habitica task list") touched := map[string]struct{}{} for id, task := range tasks { remoteTask, exists := remoteTasks[id] if !task.Done && !exists { err := client.Create(&habitica.HabiticaTODO{ Alias: id, Text: task.Name, Type: "todo", Completed: task.Done, }) if err != nil { logrus.WithError(err).WithField("task", task).Fatal("could not create task") } else { logrus.WithField("task", task).Info("created") } touched[id] = struct{}{} } if task.Done && exists && !remoteTask.Completed { err := client.Complete(remoteTask) if err != nil { logrus.WithError(err).WithField("task", task).Fatal("could not complete task") } else { logrus.WithField("task", task).Info("completed") } touched[id] = struct{}{} } } for id, task := range remoteTasks { _, exists := tasks[id] if !exists { err := client.Delete(task) if err != nil { logrus.WithError(err).WithField("task", task).Fatal("could not delete task") } else { logrus.WithField("task", task).Info("deleted") } } } }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.