{"id":13408376,"url":"https://github.com/dongyx/hardv","last_synced_at":"2026-01-16T14:23:19.372Z","repository":{"id":62347450,"uuid":"559534883","full_name":"dongyx/hardv","owner":"dongyx","description":"A Powerful Flashcard Program for Linux, macOS, and Other Unix-like Systems","archived":false,"fork":false,"pushed_at":"2024-04-08T00:08:07.000Z","size":164,"stargazers_count":30,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-31T20:30:03.318Z","etag":null,"topics":["cli","command-line","flashcard","flashcard-application","flashcard-generator","flashcards","line-oriented","linux","plaintext","quiz","shell","terminal","unix","unix-filter","unix-philosophy"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dongyx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-10-30T12:26:00.000Z","updated_at":"2024-07-31T06:04:51.000Z","dependencies_parsed_at":"2023-02-15T23:16:01.652Z","dependency_job_id":"c028d29c-38c6-49ac-9027-4c5679bad5c1","html_url":"https://github.com/dongyx/hardv","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dongyx%2Fhardv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dongyx%2Fhardv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dongyx%2Fhardv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dongyx%2Fhardv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dongyx","download_url":"https://codeload.github.com/dongyx/hardv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221472484,"owners_count":16828217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","flashcard","flashcard-application","flashcard-generator","flashcards","line-oriented","linux","plaintext","quiz","shell","terminal","unix","unix-filter","unix-philosophy"],"created_at":"2024-07-30T20:00:52.488Z","updated_at":"2026-01-16T14:23:19.367Z","avatar_url":"https://github.com/dongyx.png","language":"C","funding_links":[],"categories":["\u003ca name=\"flashcard\"\u003e\u003c/a\u003eAnki, decks and flashcards"],"sub_categories":[],"readme":"HardV\n=====\n\nHardV is a powerful flashcard program for Linux, macOS and other Unix-like systems.\nThe key features are listed below.\n\n- Almost everything can be customized,\nwith any programming language you prefer.\nE.g.:\n\n\t- HardV runs in the CLI mode by default;\n\tbut you may configure it to a TUI program,\n\tor to view images in a GUI window.\n\n\t- HardV can open the editor;\n\tsend the content you wrote\n\tto an online judging system,\n\tand determine the next quiz time by the judging result.\n\n\t- It can be used to implement\n\tkeyboard shortcut practice,\n\tcloze deletion,\n\ttext-to-speech review,\n\ttyping in the answer,\n\tand more.\n\n- The format of input files are\neasy to be parsed by both human and other Unix utilities\nlike `grep`, `sed`, and `awk`.\n\n- Metadata like scheduled time is written back to input files;\nthus all your data is in files created and managed by yourself.\n\n- HardV respects contents of input files as long as possible;\nyou could use empty lines to layout your card files.\n\n- HardV is a Unix filter in the default mode;\nthat makes it easy to be called by other programs.\nEg. You could pipe HardV to a voice synthesizer to make an audio quiz.\n\n**Table of Contents**\n\n* [Installation](#installation)\n* [Getting Started](#getting-started)\n* [Customizing Quizzes](#customizing-quizzes)\n* [Input Format](#input-format)\n* [Documentation](#documentation)\n* [Credits](#credits)\n\nInstallation\n------------\n\n- Choose a version from\nthe [release page](https://github.com/dongyx/hardv/releases);\nThe latest is always recommended unless otherwise noted in the\nrelease note.\n\n- Extract the source.\n\n- Execute in the source tree:\n\n\t~~~\n\t$ make\n\t$ sudo make install\n\t~~~\n\n`make install` copies files to `/usr/local` by default.\nThe man page `hardv(1)` is shipped with the installation.\n\nGetting Started\n---------------\n\nFirst of all, let's see the standard quiz of HardV.\n\nSuppose we have a file `input.fc` consists of flashcards.\n\n\t$ cat input.fc\n\n\tQ\thex(128) = ?\n\tA\t0x80\n\t%%\n\tQ\thex(32768) = ?\n\tA\t0x8000\n\t%%\n\tQ\tthe most famous C program from K\u0026R, second edition\n\tA\t#include \u003cstdio.h\u003e\n\t\t\n\t\tmain()\n\t\t{\n\t\t\tprintf(\"hello world\\\\n\");\n\t\t}\n\nCards are separated by `%%` on a line by itself.\nThe key and value of a field in a card are separated by a tab character.\nSubsequent lines in the value are indented by a tab character.\n(See the [*Input Format*](#input-format) section)\n\nWe could use HardV to run a quiz.\n\t\n\t$ hardv input.fc\n\t...\n\n\tQ:\n\n\t\thex(128) = ?\n\n\tPress \u003cENTER\u003e to check the answer.\n\n\tA:\n\n\t\t0x80\n\n\tDo you recall? (y/n/s)\n\ty\n\n\t...\n\nAfter running a quiz,\ntwo new fields `PREV` and `NEXT` may be inserted to the original file,\nto indicate the previous and the next scheduled quiz time.\n\n\tNEXT    2001-08-21 15:31:06 -0500\n\tPREV    2001-08-23 15:31:06 -0500\n\tQ       hex(128) = ?\n\tA       0x80\n\nYou could manually modify these two fields to tune the quiz time.\n\nThe time interval is doubled if you are able to recall the card.\nOtherwise the card will be scheduled at 24 hours later.\nSee the man page `hardv(1)` for detail.\n\nTo customize the quiz,\na `MOD` field is required to be added to the card.\nSee the [*Customizing Quizzes*](#customizing-quizzes) section.\n\nCustomizing Quizzes\n-----------------\n\nIf a card contains the `MOD` field,\nthe customized quiz is used.\nThe value of the `MOD` field is passed to `/bin/sh -c` by HardV,\nand several environment variables are set,\nfor the mod can read information about the card.\nThe exit status of the mod determines the action HardV would take\nfor the card.\n\nLet's write a simple mod called `recite`.\nWhen a card with this mod is quizzed,\nit prints the content of the `Q` field,\nthen the user is required to copy the `A` field exactly.\nIf the answer is correctly copied,\nthis mod notifies HardV that the user is able to recall the card.\nIf the answer is incorrectly copied,\nthis mod notifies HardV that the user is unable to recall the card.\nThe user can type `!` to skip the card,\nand this mod notifies HardV to update nothing.\n\nWe create a shell script named `/usr/loca/bin/recite`\nwith the following content and make it executable.\n\n\t#!/bin/sh\n\n\t# Print a blank line before quizzing a card, except the first\n\tif ! [ \"$HARDV_FIRST\" ]; then\n\t\tprintf '\\n'\n\tfi\n\tprintf 'Q: %s\\n' \"$HARDV_Q\"\t# Print the question\n\tprintf '(recite) A: '\t\t# Print the prompt\n\tread a\t\t\t\t# Read the user-input line to variable a\n\tif [ \"$a\" = \"!\" ]; then\n\t\texit 2;\t\t\t# Skip this card\n\tfi\n\tif [ \"$a\" = \"$HARDV_A\" ]; then\n\t\techo 'Correct!'\n\t\texit 0;\t\t\t# The user is able to recall\n\tfi\n\tprintf 'Wrong! The answer is: %s\\n' \"$HARDV_A\"\n\texit 1;\t\t\t\t# The user is unable to recall\n\nFor the card we want to enable this mod,\nwe add the `MOD` field with the value `recite`.\n(Ensure `/usr/local/bin` is in the `$PATH` environment variable)\n\n\t$ cat input.fc\n\n\tMOD\trecite\n\tQ\thex(128) = ?\n\tA\t0x80\n\t%%\n\tMOD\trecite\n\tQ\thex(32768) = ?\n\tA\t0x8000\n\nWhen we run `hardv` on this card, `recite` is called.\n\n\t$ hardv input.fc\n\tQ: hex(128) = ?\n\t(recite) A: 0x80\n\tCorrect!\n\n\tQ: hex(32768) = ?\n\t(recite) A: 0x800\n\tWrong! The answer is: 0x8000\n\nMods can also be embedded in the input file,\ndemonstrated by the following.\n\n\t$ cat input.fc\n\n\tMOD\n\t\t! [ \"$HARDV_FIRST\" ] \u0026\u0026 printf '\\n'\n\t\tprintf 'Q: %s\\n(recite) A: ' \"$HARDV_Q\"\n\t\tread a\n\t\t[ \"$a\" = \"!\" ] \u0026\u0026 exit 2;\n\t\tif [ \"$a\" = \"$HARDV_A\" ]; then\n\t\t\techo 'Correct!'\n\t\t\texit 0;\n\t\tfi\n\t\tprintf 'Wrong! The answer is: %s\\n' \"$HARDV_A\"\n\t\texit 1;\n\tQ\thex(128) = ?\n\tA\t0x80\n\nThis could be very handy if you want to wrap existed programs to a\nHardV mod.\n\nSee the man page `hardv(1)` for detail about how to implement a mod.\n\nInput Format\n------------\n\nA card is a key-value dictionary.\n\nThe key and the value are separated by a tab character or a newline\ncharacter.\nEvery line in the value which is not on the same line with the key\nmust start with a tab character, except for blank lines.\nFor blank lines in the value, the leading tab character is optional.\n\nCards are typically separated by `%%` on a line by itself.\nIn fact, any line starting with `%` is regarded as a card separator.\n\nEmpty cards are ignored.\nIn the standard quiz, the leading and trailing empty lines in values are ignored too.\nThus separators can be used as comments,\nand you could add empty lines for readability,\ndemonstrated by the following.\n\n\t%% This is a card set for hardv(1)\n\t%% Created at Feb 1, 1997\n\n\tQ       hex(256) = ?\n\tA\n\t\t0x100\n\n\t%%\n\n\tQ       hex(128) = ?\n\n\tA\t0x80\n\n\t%% Arithmetic cards begin\n\n\tQ       1 + 1 = ?\n\tA       2\n\t%%\n\tQ       8 - 5 = ?\n\tA       3\n\n\t%% Arithmetic cards end\n\nSee the man page `hardv(1)`\nfor the full description of the input format.\n\nDocumentation\n-------------\n\nCalling `hardv --help` prints a brief help.\nFull description is documented in the man page `hardv(1)`.\n\nTest\n----\n\nTest should only be executed after installation.\n\n\t$ make test\n\nCredits\n-------\n\nHardV was created by [DONG Yuxuan](https://www.dyx.name) in 2022.\n\nOther code contributors are listed below:\n\n- Song, Yuanjia\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdongyx%2Fhardv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdongyx%2Fhardv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdongyx%2Fhardv/lists"}