cmd

package
v0.0.0-...-1149cea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DoneCmd = &cobra.Command{
	Use:   "done",
	Short: "Mark task as Done.",
	Run: func(cmd *cobra.Command, args []string) {
		tasks, err := file_storage.LoadFromJson()
		manager := task_manager.TaskManager{
			Tasks: tasks,
		}

		if err != nil {
			fmt.Println("Error initializing load:", err)
			os.Exit(1)
		}

		if len(args) == 0 {
			fmt.Println("Requires ID as argument")
			os.Exit(1)
		}

		id, err := strconv.Atoi(args[0])
		task := *manager.Get(id)
		manager = *manager.Update(id, task.Name, task.Description, task.Cron, task.Deadline, task.Backlog, true)

		if err != nil {
			fmt.Println("Error updating task:", err)
			os.Exit(1)
		}

		err = file_storage.SaveToJson(manager.Tasks)

		if err != nil {
			fmt.Println("Error saving task:", err)
			os.Exit(1)
		}
	},
}

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func InitCommands

func InitCommands(rootCmd *cobra.Command)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL