note

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

🌳 Note - Zettelkasten Quick App

Inspired in rwxrob's zet repo, his zet bash commands and new bonzai project.

Note is a simple and quick tool to create and manage notes.

GoDoc License

Install

This command can be installed as a standalone program or composed into a Bonzai command tree.

Standalone

go install github.com/espinosajuanma/note/note@latest

Composed

package z

import (
	Z "github.com/rwxrob/bonzai/z"
	"github.com/espinosajuanma/note"
)

var Cmd = &Z.Cmd{
	Name:     `z`,
	Commands: []*Z.Cmd{help.Cmd, note.Cmd},
}

Tab Completion

To activate bash completion just use the complete -C option from your .bashrc or command line. There is no messy sourcing required. All the completion is done by the program itself.

complete -C note note

If you don't have bash or tab completion check use the shortcut commands instead.

Embedded Documentation

All documentation (like manual pages) has been embedded into the source code of the application. See the source or run the program with help to access it.

To do

  • Config zettelkasten path
  • Allow multicall
  • Add search/query command
  • Document everything
  • Add tests

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &Z.Cmd{
	Name:     `note`,
	Summary:  `taking quick notes`,
	Version:  `v0.0.1`,
	Commands: []*Z.Cmd{help.Cmd, conf.Cmd, List, New, Edit, Remove, Latest, Push},
}
View Source
var Edit = &Z.Cmd{
	Name:     `edit`,
	Aliases:  []string{"e", "ed"},
	Usage:    `<id>`,
	Summary:  `open a specific note in your editor`,
	Commands: []*Z.Cmd{help.Cmd},
	Call: func(_ *Z.Cmd, args ...string) error {
		n, err := note.Latest()
		if len(args) != 0 {
			n, err = note.GetById(args[0])
		}
		if err != nil {
			return err
		}
		n.Edit()
		if yesOrNo("Commit?") {
			n, err = note.GetById(n.Id)
			Z.Exec("git", "add", n.Id)
			Z.Exec("git", "commit", "-m", n.Title)
			Z.Exec("git", "push")
		}
		return nil
	},
}
View Source
var Latest = &Z.Cmd{
	Name:     `latest`,
	Aliases:  []string{"last"},
	Summary:  `prints latest note`,
	Commands: []*Z.Cmd{help.Cmd},
	Call: func(_ *Z.Cmd, args ...string) error {
		n, err := note.Latest()
		if err != nil {
			return err
		}
		n.Print()
		return nil
	},
}
View Source
var List = &Z.Cmd{
	Name:     `list`,
	Aliases:  []string{"ls"},
	Summary:  `list all valid notes in the current directory`,
	Commands: []*Z.Cmd{help.Cmd},
	Call: func(_ *Z.Cmd, _ ...string) error {
		list, err := note.List()
		if err != nil {
			return err
		}
		for _, v := range list {
			v.Print()
		}
		return nil
	},
}
View Source
var New = &Z.Cmd{
	Name:     `new`,
	Aliases:  []string{"add"},
	Summary:  `add a new note to the current directory`,
	Usage:    `[title]`,
	Commands: []*Z.Cmd{help.Cmd},
	Call: func(_ *Z.Cmd, args ...string) error {
		title := "Title's note"
		if len(args) != 0 {
			title = strings.Join(args, " ")
		}
		n, err := note.New(title)
		if err != nil {
			return err
		}
		n.Init()
		n.Edit()
		if yesOrNo("Commit?") {
			n, err = note.GetById(n.Id)
			Z.Exec("git", "add", n.Id)
			Z.Exec("git", "commit", "-m", n.Title)
			Z.Exec("git", "push")
		}
		return nil
	},
}
View Source
var Push = &Z.Cmd{
	Name:     `push`,
	Usage:    `<id>`,
	Aliases:  []string{"commit"},
	Summary:  `commit and push to git`,
	Commands: []*Z.Cmd{help.Cmd},
	Call: func(_ *Z.Cmd, args ...string) error {
		n, err := note.Latest()
		if len(args) != 0 {
			n, err = note.GetById(args[0])
		}
		if err != nil {
			return err
		}
		Z.Exec("git", "add", n.Path)
		Z.Exec("git", "commit", "-m", n.Title)
		Z.Exec("git", "push")
		return nil
	},
}
View Source
var Remove = &Z.Cmd{
	Name:     `remove`,
	Aliases:  []string{"rm"},
	Usage:    `<id>`,
	Summary:  `remove a specific note`,
	Commands: []*Z.Cmd{help.Cmd},
	Call: func(_ *Z.Cmd, args ...string) error {
		n, err := note.Latest()
		if len(args) != 0 {
			n, err = note.GetById(args[0])
		}
		if err != nil {
			return err
		}
		n.Print()
		if yesOrNo("Are you sure you want to remove this note?") {
			err := n.Remove()
			if err != nil {
				return err
			}
			Z.Exec("git", "add", n.Id)
			Z.Exec("git", "commit", "-m", "`Removed` "+n.Title)
			Z.Exec("git", "push")
		}
		return nil
	},
}

Functions

This section is empty.

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