cmd

package
v0.0.0-...-19ed411 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListAllBoards = &cobra.Command{
	Use:   "list",
	Short: "List all the boards",
	Long:  `List all boards saved in the user config.`,
	Run: func(cmd *cobra.Command, args []string) {
		config, err := domain.GetUserConfig()
		if err != nil {
			log.Fatalf("Failed to get the user config. %s", err)
		}

		t := table.NewWriter()
		t.SetOutputMirror(os.Stdout)
		t.AppendHeader(table.Row{"#", "Board", "Number of tasks", "Progress", "Path"})

		for i, board := range config.Boards {
			totalNumberOfTasks := 0
			numberOfCompletedTasks := 0
			for i, columnName := range board.Columns {
				totalNumberOfTasks += len(board.Tasks[columnName])

				if i == len(board.Columns)-1 {
					numberOfCompletedTasks += len(board.Tasks[columnName])
				}
			}

			progress := float32(0)
			if totalNumberOfTasks != 0 {
				progress = float32(numberOfCompletedTasks) / float32(totalNumberOfTasks)
			}

			t.AppendRow([]any{
				i + 1,
				board.Name,
				totalNumberOfTasks,
				fmt.Sprint("%", int(progress*100)),
				board.Dir,
			})
		}
		t.AppendSeparator()

		t.Render()
	},
}
View Source
var OpenConfig = &cobra.Command{
	Use:   "config",
	Short: "Opens the config file",
	Long:  `Opens the config file for all projects in Vi.`,
	Run: func(cmd *cobra.Command, args []string) {
		path, err := domain.GetConfigFilePathBasedOnOS()
		if err != nil {
			log.Fatalln("Failed to open up the config. ", err)
		}

		editor := os.Getenv(vars.EditorOfChoice)
		if editor == "" {
			editor = "vi"
		}

		err = utils.OpenInEditor(editor, path)
		if err != nil {
			log.Fatalf("Failed to open the config file in %s. %s\n", editor, err)
		}
	},
}
View Source
var OpenLogs = &cobra.Command{
	Use:   "logs",
	Short: "Opens the logs file",
	Long:  `Opens the logs file for all projects in Vi.`,
	Run: func(cmd *cobra.Command, args []string) {
		path, err := domain.GetLogsFilePathBasedOnOS()
		if err != nil {
			log.Fatalln("Failed to open up the log file. ", err)
		}

		editor := os.Getenv(vars.EditorOfChoice)
		if editor == "" {
			editor = "vi"
		}

		err = utils.OpenInEditor(editor, path)
		if err != nil {
			log.Fatalf("Failed to open the config file in %s. %s\n", editor, err)
		}
	},
}
View Source
var Version = &cobra.Command{
	Use:   "version",
	Short: "Displays the version of gotasks.",
	Long:  `Displays the version of gotasks.`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("gotasks version: %s\n", version)
	},
}

Functions

func Execute

func Execute()

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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