Help us shape the future of Go! Take the 2026 Go Developer Survey

clinote

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

README

Build Status Go Report Card

CLInote

CLInote is a command line client for Evernote inspired by geeknote.

CLInote allows you to:

  • Create notes
  • Send the note content to stdout
  • Edit notes in your $EDITOR
  • Create new notebooks
  • Search for notes

Installation

From source:

go get -v github.com/TcM1911/clinote/cmd

Download pre-build binary from the release page.

Authorize to Evernote via OAuth

Before you can use any features, you need to authorize CLInote to access youre notes. To authorize run the command:

clinote user login

If you have your default browser defined in the $BROWSER environment variable, CLInote will open the link in your default browser.

Create a new note

A new note can be created with the command shown below. A title needs to be given for the note. If no notebook is given, the default notebook will be used. The new note can be open in the $EDITOR by using the edit flag.

clinote note new --title "note title" [--notebook "notebook name"] [--edit]

Edit note

Notes can be edited using the edit command. If no flags are set, the note is opened with the editor defined by the environment variable $EDITOR. The first line will be used as the note title and the rest is encoded as the note content.

To change to title, the title flag can be used.

The note can be moved to another notebook by defining the new notebook with the notebook flag.

clinote note edit "note title" [--title "new note title"] [--notebook "new notebook"]

Show note content

You can send the note content to the standard out with the command below:

clinote note "note title"

Remove a note

Delete moves the note into the trash. The note may still be undeleted, unless it is expunged. To expunge the note you need to use the official client or the web client.

clinote note delete "note title"

Search for notes

To search for notes, use the list command as shown below.

clinote note list [--count 20] [--search "search term"] [--notebook "notebook name"]

The search term flag can be used to define a search term to be used. The search can be restricted to a notebook by using the notebook flag.

Count can be used to restrict the maximum number of notes returned.

If no search term is given, a wild card search will be used. The notes will be sorted by the modified time.

View/edit/remove notes returned in the search list

You can view, edit, or remove notes returned by the list command using the note's index number. For example to show the content of the first note in the list, use the following command:

clinote note 1

To remove the 5th note in the list, use:

clinote note delete 5

Create a new notebook

To create a new notebook, use the command below:

clinote notebook new "notebook name" [--default] [--stack "Stack name"]

Edit a notebook

To edit a notebook use this command:

clinote notebook edit "notebook name" [--name "new notebook name"] [--stack "new stack"]

List all notebooks

To list all notebooks, use the notebook list command:

clinote notebook list

Documentation

Index

Constants

View Source
const (
	// XMLHeader is the header that needs to added to the note content.
	XMLHeader string = `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">`
)

Variables

View Source
var (
	// NoteFilterOrderCreated sorts the notes by create time.
	NoteFilterOrderCreated = int32(1)
	// NoteFilterOrderUpdated sorts the notes by update time.
	NoteFilterOrderUpdated = int32(2)
	// NoteFilterOrderRelevance sorts the notes by relevance.
	NoteFilterOrderRelevance = int32(3)
	// NoteFilterOrderSequenceNumber sorts the notes by sequence number.
	NoteFilterOrderSequenceNumber = int32(4)
	// NoteFilterOrderTitle sorts the notes by title.
	NoteFilterOrderTitle = int32(5)
)
View Source
var (
	// ErrNoNotebookFound is returned if no matching notebook was found.
	ErrNoNotebookFound = errors.New("no notebook found")
	// ErrNoNotebookCached is returned when trying to update a notebook
	// that hasn't been pulled from the server.
	ErrNoNotebookCached = errors.New("no notebook found")
)
View Source
var (
	// DefaultNotebookCacheTime is the default time limit for when the
	// list is considered outdated.
	DefaultNotebookCacheTime = 24 * time.Hour
)
View Source
var (
	// ErrNoNoteFound is returned if search resulted in no notes found.
	ErrNoNoteFound = errors.New("no note found")
)

Functions

func ChangeTitle

func ChangeTitle(db Storager, ns NotestoreClient, old, new string) error

ChangeTitle changes the note's title.

func CreateNotebook

func CreateNotebook(ns NotestoreClient, notebook *Notebook, defaultNotebook bool) error

CreateNotebook creates a new notebook.

func DeleteNote

func DeleteNote(db Storager, ns NotestoreClient, title, notebook string) error

DeleteNote moves a note from the notebook to the trash can.

func MoveNote

func MoveNote(db Storager, ns NotestoreClient, noteTitle, notebookName string) error

MoveNote moves the note to a new notebook.

func SaveChanges

func SaveChanges(ns NotestoreClient, n *Note, useRawContent bool) error

SaveChanges updates the changes to the note on the server.

func SaveNewNote

func SaveNewNote(ns NotestoreClient, n *Note, raw bool) error

SaveNewNote pushes the new note to the server.

func UpdateNotebook

func UpdateNotebook(db Storager, ns NotestoreClient, name string, notebook *Notebook) error

UpdateNotebook updates the notebook.

Types

type APIClient

type APIClient interface {
	// GetNoteStore returns the note store for the user.
	GetNoteStore() (NotestoreClient, error)
	// GetConfig returns the client's configuration.
	GetConfig() Configuration
}

APIClient is the interface for the api client.

type Configuration

type Configuration interface {
	io.Closer
	// GetConfigFolder returns the folder used to store configurations.
	GetConfigFolder() string
	// GetCacheFolder returns the cache folder.
	GetCacheFolder() string
	// Store returns the backend storage.
	Store() Storager
}

Configuration is the interface for a configuration struct.

type DefaultConfig

type DefaultConfig struct {
	// DB is the backend storage for the client.
	DB Storager
}

DefaultConfig uses shared config and cache folder with other instances of DefaultConfig structs.

func (*DefaultConfig) Close

func (c *DefaultConfig) Close() error

Close closes the BoltDB handler.

func (*DefaultConfig) GetCacheFolder

func (*DefaultConfig) GetCacheFolder() string

GetCacheFolder returns the folder used to cache.

func (*DefaultConfig) GetConfigFolder

func (*DefaultConfig) GetConfigFolder() string

GetConfigFolder returns the folder used to store configurations.

func (*DefaultConfig) Store

func (c *DefaultConfig) Store() Storager

Store returns a handler to BoltDB.

type Note

type Note struct {
	// Title is the note tile.
	Title string
	// GUID is the unique identifier.
	GUID string
	// Body contains the body of the note.
	Body string `xml:",innerxml"`
	// MD is a Markdown representation of the note body.
	MD string
	// MDHash is the MD5 hash of the MD body.
	MDHash [16]byte
	// Deleted is set true if the note is marked for deletion.
	Deleted bool
	// Notebook the note belongs to.
	Notebook *Notebook
	// Created
	Created int64
	// Updated
	Updated int64
}

Note is the structure of an Evernote note.

func FindNotes

func FindNotes(ns NotestoreClient, filter *NoteFilter, offset int, count int) ([]*Note, error)

FindNotes searches for notes.

func GetNote

func GetNote(db Storager, ns NotestoreClient, title, notebook string) (*Note, error)

GetNote gets the note metadata in the notebook from the server. If the notebook is an empty string, the first matching note will be returned.

func GetNoteWithContent

func GetNoteWithContent(db Storager, ns NotestoreClient, title string) (*Note, error)

GetNoteWithContent returns the note with content from the user's notestore.

type NoteFilter

type NoteFilter struct {
	// NotebookGUID is the GUID for the notebook to limit the search to.
	NotebookGUID string
	// Words can be a search string or note title.
	Words string
	// Order
	Order int32
}

NoteFilter is the search filter for notes.

type Notebook

type Notebook struct {
	// Name is the notebook's name
	Name string
	// GUID is the notebook's GUID.
	GUID string
	// Stack is the stack that the notebook belongs too.
	Stack string
}

Notebook is a struct for the notebook.

func FindNotebook

func FindNotebook(db Storager, ns NotestoreClient, name string) (*Notebook, error)

FindNotebook gets the notebook matching with the name. If no notebook is found, nil is returned.

func GetNotebook

func GetNotebook(ns NotestoreClient, guid string) (*Notebook, error)

GetNotebook returns a notebook from the user's notestore.

func GetNotebooks

func GetNotebooks(db Storager, ns NotestoreClient, forceSync bool) ([]*Notebook, error)

GetNotebooks returns all the user's notebooks.

type NotebookCacheList

type NotebookCacheList struct {
	// Notebooks is the list of notebooks.
	Notebooks []*Notebook
	// Timestamp of when the list was created.
	Timestamp time.Time
	// Limit is the until the list outdated.
	Limit time.Duration
}

NotebookCacheList is a list of cached notebooks.

func NewNotebookCacheList

func NewNotebookCacheList(notebooks []*Notebook) *NotebookCacheList

NewNotebookCacheList creates a cache list with the default expiration limit.

func NewNotebookCacheListWithLimit

func NewNotebookCacheListWithLimit(notebooks []*Notebook, limit time.Duration) *NotebookCacheList

NewNotebookCacheListWithLimit creates a new cache list with the given expiration limit.

func (*NotebookCacheList) IsOutdated

func (n *NotebookCacheList) IsOutdated() bool

IsOutdated returns true if the list has expired.

type NotestoreClient

type NotestoreClient interface {
	// FindNotes searches for the notes based on the filter.
	FindNotes(filter *NoteFilter, offset, count int) ([]*Note, error)
	// GetAllNotebooks returns all the of users notebooks.
	GetAllNotebooks() ([]*Notebook, error)
	// GetNotebook
	GetNotebook(guid string) (*Notebook, error)
	// CreateNotebook
	CreateNotebook(b *Notebook, defaultNotebook bool) error
	// GetNoteContent gets the note's content from the notestore.
	GetNoteContent(guid string) (string, error)
	// UpdateNote update's the note.
	UpdateNote(note *Note) error
	// DeleteNote removes a note from the user's notebook.
	DeleteNote(guid string) error
	// CreateNote creates a new note on the server.
	CreateNote(note *Note) error
	// UpdateNotebook updates the notebook on the server.
	UpdateNotebook(book *Notebook) error
}

NotestoreClient is the interface for the notestore.

type Settings

type Settings struct {
	// APIKey is the user's OAuth session key.
	APIKey string
}

Settings is a struct holding the user's settings for the application.

type Storager

type Storager interface {
	io.Closer
	GetSettings() (*Settings, error)
	StoreSettings(*Settings) error
	// GetNotebookCache returns the stored NotebookCacheList.
	GetNotebookCache() (*NotebookCacheList, error)
	// StoreNotebookList saves the list to the database.
	StoreNotebookList(list *NotebookCacheList) error
	// SaveSearch stores a note search to the database.
	SaveSearch([]*Note) error
	// GetSearch returns a saved note search from the database.
	GetSearch() ([]*Note, error)
}

Storager is the interface for backend storage.

Directories

Path Synopsis
api
Package api provides interface for the Evernote API.
Package api provides interface for the Evernote API.

Jump to

Keyboard shortcuts

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