Skip to content

Documentation Status License Coverage

anki-cli

anki-cli aims to be a command line interface alternative to the Anki desktop application.

Anki is a free and open-source flashcard program that utilizes spaced repetition in order to memorize many things easily (cf. https://docs.ankiweb.net/#/ and https://apps.ankiweb.net/index.html).


Disclaimer

  • I'm not a professional Python developer, please help me increase the code quality of anki-cli.
  • This software is currently WORK IN PROGRESS: it is unstable, untested and not even really functional... Use it at your own risk, I encourage you to make frequent backups.

Table of contents


Sources and motivations

This tool is heavily inspired by the following projects, check them, they might be enough for what you need:

As interesting as all these projects are, they all require the official Anki gui application to be running and/or to be installed (at least at some point, e.g. to identify and connect before the first sync). Moreover, many of them are no longer actively maintained.

This project tries to provide an alternative, as full-featured as possible, addressing these aspects.


Status

  • anki-cli is now build against anki 2.1.16 (commit 4bc33e2f), let's hope this version remains compatible with the last official anki long enough not to worry about it (too much).

  • This application is a work in progress, it is far from being functional and even farther from being considered reliable.


Prerequisiste(s)


User guide


Developer guide


TODO / features

High priority

  • avoid anki-submodule dependency: become anki compatible without relying on the anki project
  • anki-cli.conf file (containing various settings)
  • sync
    • sign in / sign out
    • sync triggering (remote AnkiWeb content becomes the same as the local one and vice versa)
    • sync conflicts management (download and override, or upload and override, backup anyway)
  • backups (by default, backup last 10 sync Anki2 dirs, and last 10 manually triggered backups)
    • backups settings: backups location, max number of backups
    • trigger backup
    • restore backup
  • full local mode (without AnkiWeb account, so without sync)
    • ability to create and use a non-AnkiWeb account
  • notes
    • find note(s) with filtered search
    • create a note (beware of duplicates)
    • delete a note (with confirmation option)
    • update a note (w/o altering it's associated card's stats, or resetting stats if wanted)
      • edit mode (parser needed)
    • add tag(s) (beware of duplicates)
    • delete tag(s) (with confirmation option)
  • cards
    • find card(s) with filtered search
    • create a card (beware of duplicates)
    • delete a card (with confirmation option)
    • update a card
      • edit mode (parser needed)
  • models
    • print models
    • find model(s) with filtered search
    • create a model (beware of duplicates)
    • delete a model (with confirmation option)
    • update a model
      • edit mode (parser needed)
  • decks
    • list decks or find deck(s) with filtered search
    • create a deck (beware of duplicates)
    • delete a deck (with confirmation option)
    • update a deck (add cards / remove cards)
    • import a deck (beware of conflicting notes id, did, mid etc.)
    • export a deck
    • support deck configuration (dconf in col table)
    • support subdecks and superdecks
  • file parser for deck management
    • define how a file can be parsed (syntax, examples) and document it
    • -p --pretend flag: show what would have happened if the parsing was for real.
    • fields to create/update deck, model(s), card(s), note(s) (beware of duplicated ids)
    • field to define default deck
    • field to define default model id
    • field to override default card
    • auto card (new note will also create new card on the fly, based on the default card)
    • cards stats: by default cards stats are not altered, but they could be reset if wanted
    • auto note id (note id will be auto-write by the parser to the file, enabled by default)
    • -o --override flag: must be specified to allow overrides (updates and deletions) with a warning and confirmation msg. -y --yes flag to auto confirm.
    • is there a way to make sure a parsed note is beeing correctly modified and not accidentaly overrided (e.g. because of an mistake in the note id)? ==> a last-user field to parse.
    • field to define the last-user of the file, raising confirmation prompt if the last user do not match the current anki-cli user
    • print warning and confirmation msg, if the last-user do not match the current user
    • auto update/add last-user field (at the top of the file), based on AnkiWeb user name. Enabled by default: -a --auto-last-user false, to avoid default
    • prefix ids: prefix all the following ids by this int (block to parse). Prefix ids is auto generated by the parser by default (parser will write it at the top of the file) based on the file name (/! duplicates). -i --auto-ids false, to avoid default
    • new file check command to warn about duplicated ids and other errors and incoherences.
    • vim snippet to insert note easily

Low priority


WIP notes

  • ids (decks, notes, cards, models) smaller than or equal to 0 must be forbidden.

According to this and this summurized licenses descriptions (respectively the licences used by the anki-cli project and the anki project), here are the legal requirements of the anki-cli project:

  • The anki-cli license (MIT) is compatible with the anki v2.1.16 license (AGPL3), cf. wikipedia about license compatibility.

  • The anki-cli project uses source code from the anki v2.1.16 repository. This repository is imported in the anki-cli project as a git submodule, including it's copyright: "Ankitects Pty Ltd and contributors", and it's license.

  • A smaller part of the anki v2.1.16 source code is also imported and modified outside the git submodule: in the anki-cli source code directory "src" (note that this directory does not only contains modified anki v2.1.16 source code but also original anki-cli source code). Even if those source code files have been (sometimes extensively) modified, they always refer to their original file and always include the original license and their original copyright (the details of the changes made can be checked by comparing the modified and the originals files using a simple comparison tool, e.g. diff).

  • The significant changes made to the imported and modifed anki v2.1.16 source code consist in transforming anki from a graphical user interface (GUI) to a command line interface (CLI).

  • The anki-cli sources will always be available here

  • The build and install instructions are included in this document (cf. above "install" sub-sections).