cmd

package
v0.0.0-...-766887c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "gitodo",
	Short: "The stupid to-do list application for git projects",
	Long: `
gitodo is a to-do list companion for git projects that ties to-do items to git 
repositories and branches without storing any files in the actual repositories.

A minimalist tool that helps the busy developers to:

 - keep track of what they've done and what they need
   to do per branch
 - add ideas in the queue for later
 - make stashing and popping of changes easier
 - craft commit messages based on the work done
 - prepare changelists
 - track time
 - view reports

All configuration is read from git and the environment, no yaml files needed.

Running the application without arguments will either:

  - open up the editor to add items if none are found
  - open a TUI screen where to-do items can be managed

The invoked editor will be the same one that git invokes.

To-do items do not have a priority. The top-most item should be always the one 
with the top priority, and commands like "what" and "done" read items from top
to bottom. Use the TUI screen to change the order of the items.

When stashing changes for an item, the "--include-untracked" flag will be 
passed to git, so if you don't want to have some untracked files to be stashed,
make sure to add them to .gitignore file or move them somewhere else. 

By default, gitodo will store the database file into the current user's home
directory. To override the path to the database file, set GITODO_DB environment
variable to a desired path to the file.

  `,

	Run: func(cmd *cobra.Command, args []string) {
		env, tdb := MustInit()
		projId := tdb.FetchProjectId(env.ProjDir, env.Branch)
		count := tdb.TodoCount(projId)

		_, err := tdb.CheckTimer(projId)
		HandleTimerError(err)

		if count == 0 {
			tmpfile, err := shell.NewItemsTmpFile()
			ExitOnError(err, 1)
			err = tmpfile.Edit(env.Editor, 3)
			ExitOnError(err, 1)
			items, err := tmpfile.ReadItems()

			tmpfile.Delete()

			ExitOnError(err, 1)
			tdb.AddTodos(projId, items)

			fmt.Printf("Added %d item(s) to %q\n", len(items), env.Branch)
		} else {
			ui.RunTodoListUI(env, tdb)
		}
	},
}

RootCmd represents the base command when called without any subcommands

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 ExitOnError

func ExitOnError(err error, code int)

func HandleTimerError

func HandleTimerError(err error)

func MustInit

func MustInit() (*shell.DirEnv, *base.TodoDb)

MustInit collects data and creates instances necessary for the app to function

Types

This section is empty.

Jump to

Keyboard shortcuts

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