commands

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: GPL-3.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VersionMajor    = 0
	VersionMinor    = 5
	VersionRevision = 0
)

Version information

View Source
var DeleteBookCmd = &cobra.Command{
	Use:   "book <book name>",
	Short: "Delete a Book and all of it's Notes",
	Run:   deleteBookCmdRun,
}

DeleteBookCmd delete a book and all of it's Notes

View Source
var DeleteCmd = &cobra.Command{
	Use:     "delete",
	Aliases: []string{"del", "remove", "rm"},
	Short:   "Delete Note or Notebook",
}

DeleteCmd delete Note or Notebook

View Source
var DeleteNoteCmd = &cobra.Command{
	Use:   "note <note id...>",
	Short: "Delete Note from Book",
	Run:   deleteNoteCmdRun,
}

DeleteNoteCmd Delete Note from Book

View Source
var EditBookCmd = &cobra.Command{
	Use:   "book <new book_name>",
	Short: "Edit working Book's name",
	Long:  `Edit the working Book's name. This requires re-index the Book`,
	Run:   editBookCmdRun,
}

EditBookCmd edit Book's name

View Source
var EditCmd = &cobra.Command{
	Use:     "edit",
	Aliases: []string{"update"},
	Short:   "Edit Note or Notebook",
}

EditCmd edit Note or Notebook

View Source
var EditNoteCmd = &cobra.Command{
	Use:   "note <note id>",
	Short: "Edit note",
	Long:  `Opens an editor (default vim) to allow you to edit a Note`,
	Run:   editNoteCmdRun,
}

EditNoteCmd Edit note

View Source
var ExportCmd = &cobra.Command{
	Use:   "export [flags]",
	Short: "Export all Notes, Books, and Tags",
	Long: `Export all Notes, Books, and Tags using the QNOT file format.

See the documentation in github.com/anmil/quicknote/cmd/shard/encoding/binary.go
for the specifications of the format. This command is useful for backing up all
of your notes or transferring them to another system.

See the help docs for the "import" command for how importing is done and conflicts
are dealt with.

The output is written to stdout by default, use the '-o' flag to write to a file.

Qnote can also compress the output with gzip by specifying the '-c' flag.`,
	Run: exportCmdRun,
}

ExportCmd Export all Notes, Books, and Tags

View Source
var GetBookCmd = &cobra.Command{
	Use:     "book",
	Aliases: []string{"books"},
	Short:   "List all books",
	Run:     getBookCmdRun,
}

GetBookCmd List all books

View Source
var GetCmd = &cobra.Command{
	Use:              "get",
	Aliases:          []string{"list", "ls"},
	Short:            "Get/List Notes, Notebook, Tags",
	PersistentPreRun: preseistentPreGetRoot,
}

GetCmd get/list Notes, Notebook, Tags

View Source
var GetNoteAllCmd = &cobra.Command{
	Use:   "all",
	Short: "List all Notes for all Books",
	Long: `List all notes in all Books

This is the same as 'gnote ls notes' except it returns all Notes in all Books`,
	Run: getNoteAllCmdRun,
}

GetNoteAllCmd Gets all Notes

View Source
var GetNoteCmd = &cobra.Command{
	Use:     "note [flags] [note id...]",
	Aliases: []string{"notes"},
	Short:   "List all notes in the working Book, or all notes for the given [note id...]",
	Long: `List all Notes for the Book, or Notes for the given IDs.

Prints Notes in the format given by '-f', see '-f' docs for all available
options.`,
	Run: getNoteCmdRun,
}

GetNoteCmd Gets all Notes, or Notes for the given IDs

View Source
var GetTagCmd = &cobra.Command{
	Use:     "tag",
	Aliases: []string{"tags"},
	Short:   "lists all tags for the working Book",
	Run:     getTagCmdRun,
}

GetTagCmd lists all tags for the working Book

View Source
var ImportCmd = &cobra.Command{
	Use:   "import [flags] [<input-file>]",
	Short: "Imports Notes, Books, and Tags from a QNOT file",
	Long: `Imports Notes, Books, and Tags from a QNOT file

Imports notes from a QNOT file that is read from stdin or a file passed
as an argument.

If the QNOT file contains a book that is already in the database it is not
recreated and the existing book is used. The same goes for Tags.

By default the importer checks if a Note already exists. A Note is considered
to be equal if the Book, Type, Title, and Body are the same. If a duplicate
is found the Note is skipped. The duplicate check can be disabled with the
"--skip-dup-check" flag in which case all Notes are saved as new Notes.

Skipping the check is a good idea if you know there are no duplicates -- the
importer will run faster since it does not have to search the database for
existing Notes.

A Note's ID is not preserved
Created dates are preserved
Modified dates are set to the current time (set --preserve-modified to disable this)

Be sure to set the "-c" flag if the QNOT file is compressed with gzip. If you
pass the file name in as an argument and it ends with ".gz" Qnote will automatically
treat it as compressed.`,
	Run: importCmdRun,
}

ImportCmd Imports Notes, Books, and Tags from a QNOT file

View Source
var MergeBooksCmd = &cobra.Command{
	Use:   "merge [flags] <book_name 1> <book_name 2>",
	Short: "Merge all notes from <book_name 1> into <book_name 2>",
	Long: `Merge all of the notes from <book_name 1> into <book_name 2>. Than <book_name 1>
is deleted and <book_name 2> is re-indexed.`,
	Run: mergeBooksCmdRun,
}

MergeBooksCmd Merge one book into another

View Source
var MoveNotesIDsCmd = &cobra.Command{
	Use:   "move [flags] <book_name> <note_id...>",
	Short: SplitBookIDsCmd.Short,
	Long:  SplitBookIDsCmd.Long,
	Run:   SplitBookIDsCmd.Run,
}

MoveNotesIDsCmd See SplitBookIDsCmd

View Source
var NewCmd = &cobra.Command{
	Use:     "new",
	Aliases: []string{"create", "add"},
	Short:   "Create new Note or Notebook",
}

NewCmd create new Note or Notebook

View Source
var NewNoteCmd = &cobra.Command{
	Use:   "note",
	Short: "Create a new basic Note",
	Long: `Create a new note to store and index

Opens an editor (default vim) to allow you to enter a new Note. The Note text
is parsed using the first line as the Note's title. All other lines are used
as the Note's body. Any word starting with '#' character is parsed as a Tag.
Tags can be in either the title or the body.`,
	Run: newNoteCmdRun,
}

NewNoteCmd Create a new basic note

View Source
var NewNoteFromJSONCmd = &cobra.Command{
	Use:   "json [<json>]",
	Short: "Create new notes from JSON",
	Long: fmt.Sprintf(`Create new notes from JSON

JSON must be in the format

[
	...
	{
		"title": "<title>",
		"type": "<type>",
		"tags": ["<tag1>", "<tag2>", ...],
		"body": "<body>",
		"book": "<book>"
	},
	...
]

"type" must be one of the following: %s
If the book does not exists, it will be created

If <json> is note given, qnote will read from stdin
`, strings.Join(note.NoteTypes, ", ")),
	Run: newNoteFromJSONCmdRun,
}

NewURLNoteCmd Create new notes from JSON

View Source
var NewURLNoteCmd = &cobra.Command{
	Use:   "url <url>",
	Short: "Create a new url note",
	Long: `Creates a new note with URL type

DO NOT USE THIS IF YOU DO NOT WANT A REQUEST SENT TO THE URL

This is the same as calling 'qnote note new -t url <url>

This command preforms a GET request on the given URL. If a valid response
is given, it will parse the HTML for the 'title', keywords', and 'description'
meta tags and pre-fills the editor with this information.
`,
	Run: newURLNoteCmdRun,
}

NewURLNoteCmd Create a new url note

View Source
var NewbookCmd = &cobra.Command{
	Use:   "book <book_name...>",
	Short: "Create a new Book",
	Long: `Create a new Book

Books allow you to organize collections of notes. Every Note must belong to a
Book. All commends (unless stated otherwise) operates only on one book. Such as,
if you call 'qnote ls notes', it only list the notes for the working Book. The
working Book can be changed with the '-n' flag, or you can changed the default
Book in the config file. In most cases, it is not advised to create to many
books, but they are useful to keeping work notes separated from personal.`,
	Run: newbookCmdRun,
}

NewbookCmd Create a new Book

View Source
var RootCmd = &cobra.Command{
	Use:   "qnote",
	Short: "Create and search tens of thousands of notes",
	Long: `Qnote allows you to quickly create and search tens of thousands of short notes.

Create Books to organize collections of notes.
Add tags to notes for more accurate searching.
Export your notes in text, csv, and json.

Notes are stored in an SQLite database (support for more databases is coming).
Searching is provided by Bleve by default, or Elasticsearch with some extra setup.
`,
	PersistentPreRun:  PreseistentPreRunRoot,
	PersistentPostRun: PreseistentPostRunRoot,
}

RootCmd Create and search tens of thousands of notes

View Source
var SearchCmd = &cobra.Command{
	Use:   "search <query>",
	Short: "Search notes",
	Long: `Search all notes in the working Book (see '-n').

Query syntax depends on the index provider that is configured. This command
(when '-q' is not given) uses a Phrase Prefix query. Results match on all
given words in the query string with the last word used as a prefix. For
better documentation on how this works. See the index providers docs

Bleve (default): http://www.blevesearch.com/docs/Query/
ElasticSearch: https://www.elastic.co/guide/en/elasticsearch/guide/current/_query_time_search_as_you_type.html

To use the QueryStringQuery syntax set the '-q' flag
	Example (ElasticSearch): title:term1 AND tags:term2 NOT (body:term3 OR body:term4)
`,
	Run: searchCmdRun,
}

SearchCmd Search notes

View Source
var SearchReindexCmd = &cobra.Command{
	Use:   "reindex",
	Short: "Re-indexes all Notes in all Books",
	Long: `Use this command to re-index all of your Notes from all Books

If you change the index provider, copy or replace the qnote.db. You need to
call this in order to use the search command.

Re-indexing can take several minutes depending on the number of notes and
the index provider used.`,
	Run: searchReindexCmdRun,
}

SearchReindexCmd Re-indexes all Notes in all Books

View Source
var SplitBookIDsCmd = &cobra.Command{
	Use:   "ids [flags] <book_name> <note_id...>",
	Short: "Moves the given <note_id...> to a new or existing Book <book_name>",
	Long:  `Moves the Notes for the given <note_id...> into a new or existing Book.`,
	Run:   splitBooksIDsCmdRun,
}

SplitBookIDsCmd splits one book into two book using QueryStringQuery

View Source
var SplitBookQueryCmd = &cobra.Command{
	Use:   "query [flags] <book_name> <query_string_query>",
	Short: "splits the working Book into two Books using QueryStringQuery",
	Long: `Splits the working Book into two Books. All notes matching the query will be
moved into the Book <book_name>. If <book_name> already exists, the Notes
matching the query are merged into the exciting Book. For docs on the syntax for
QueryStringQuery see the docs for 'qnote search'.`,
	Run: splitBooksQueryCmdRun,
}

SplitBookQueryCmd splits one book into two book using QueryStringQuery

View Source
var SplitCmd = &cobra.Command{
	Use:   "split",
	Short: "Split Book",
}

SplitCmd splits Books

View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "Print the version of qnote",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("Quick Note %d.%d.%d\n",
			VersionMajor, VersionMinor, VersionRevision)
	},
}

VersionCmd prints the version information

Functions

func PreseistentPostRunRoot

func PreseistentPostRunRoot(cmd *cobra.Command, args []string)

PreseistentPostRunRoot runs after the Root Command and any child commands that do not override it.

func PreseistentPreRunRoot

func PreseistentPreRunRoot(cmd *cobra.Command, args []string)

PreseistentPreRunRoot runs before the Root Command and any child commands that do not override it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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