View Source mix anki_connect (anki_connect v0.1.1)

Provides functionality to interact via a command-line interface (CLI) with AnkiConnect, a plugin for the Anki flashcard application.

To use the AnkiConnect task, run the following command in your terminal:

mix anki_connect <action> [params]

where <action> is the action you want to perform and [params] are optional parameters required by the action.

List of actions can be found in the AnkiConnect module documentation.

If a function expects a map with some keys, those keys should be written as parameters in the command line (preceded with -- and with _ replaced with -).

examples

Examples

> mix anki_connect deck_names
["Current", "Current::English", "Default"]
> mix anki_connect create_deck --deck='TEST DECK'
1684945081956
> mix anki_connect delete_decks --decks='["TEST DECK"]'
Done.

Let's assume that note with ID 1684946786121 has been already created.

> mix anki_connect add_tags --notes='[1684946786121]' --tags='some tag'
Done.
> mix anki_connect add_tags --notes='[1684946786121]' --tags='other tag'
Done.
> mix anki_connect get_note_tags --note='1684946786121'
["other tag", "some tag"]

passing-nested-structures-as-parameters

Passing nested structures as parameters

Maps and lists in the command line should be written as JSON encoded strings with keys in snake_case styling. For example, to add a note to a deck, you should run the following command:

> mix anki_connect add_note --note='{"deck_name": "TEST DECK", "model_name": "Basic", "fields": {"Front": "front content", "Back": "back content"}}'
1684946786121

which is an equivalent to the following Elixir code:

AnkiConnect.add_note(%{
  note: %{
    deck_name: "TEST DECK",
    model_name: "Basic",
    fields: %{
      Front: "front content",
      Back: "back content"
    }
  }
})

Full list of available actions can be found in the AnkiConnect module documentation.

post-actions

Post-actions

Post-actions ordain what should be done when task was succesfully completed. They are defined as params which starts with --with- prefix.

Available post-actions:

Example:

> mix anki_connect create_deck --deck='TEST DECK' --with-sync
1684945081956
Syncing...
Synced!